Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2017, 02:26 AM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,743
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Communication between a Class and DB NPC?

Goal: For this example each time a player says "debug" the database is triggered which it in turn triggers back to the class and updates every NPC that is joined to it.

So this is where I started which works.
PHP Code:
function onPlayerChats() {
  if (
player.chat == "debug") {
    
DATABASE.triggerdatabase(); // database has the public function 
  
}

My Problem: Now I want the database to trigger back to the class in order to update it. I've tried sending it back a public function but without an identifier the database can't find the class. For whatever reason level NPCs and classes can't have identifiers, and you can't use the class name as an identifier. I've tried to use triggerAction. I've also tried to join the database to the class, but the database catches the update and applies it to itself and doesn't update the other classes.

So bottom line is I need help again. Can what I'm trying to do be accomplished?
__________________
Save Classic!

Last edited by maximus_asinus; 08-28-2017 at 02:36 AM..
Reply With Quote
  #2  
Old 08-28-2017, 04:10 AM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Post

One way to do it is to use trigger()

PHP Code:
// DbNpc "Kirko"
public function doSomething(cool)
{
  
this.trigger("onDidSomething"temp.cool);
}

// lvel npc
function onCreated()
{
  
Kirko.doSomething("Test");
}

function 
Kirko.onDidSomething(cool)
{
  
this.chat temp.cool// Will beset to "test"

or you can pass the npc just by using "this"
PHP Code:
// Dbnpc
public function doSomething(npc)
{
  
temp.npc.chat "I did something";
}

// level npc
function onCreated()
{
  
Kirko.doSomething(this);

orrrr
PHP Code:
// dbnpc
public function doSomething()
{
  
temp.callstack getCallStack();
  
temp.npc temp.callstack[temp.callstack.size() - 1].scriptcallobject;
  
temp.npc.chat "test";
}

// level npc
function onCreated()
{
  
Kirko.doSomething(); // npc chat now set to "Test"

Reply With Quote
  #3  
Old 08-28-2017, 08:31 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,743
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Very interesting stuff happening there. I wasn't aware of the trigger command. It will be useful to know for the future.

I did have trouble with the 1st and 3rd example. The 1st example wouldn't execute Kirko.doSomething("Test") outside of the onCreated() function. The 3rd example just didn't work period. The 2nd method worked but didn't have the effect I was looking for.

So I'm still looking to find a way to update every NPC that has joined a specific class. These methods seem to only impact the specific NPC that triggers the doSomething command.
__________________
Save Classic!
Reply With Quote
  #4  
Old 08-29-2017, 01:32 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
There is other methods

example

PHP Code:
// Database NPC name = Kirko 

const CLASS = "kirko_test";
public function 
update(temp.lvl)  {
  for(
temp.npcfindlevel(temp.lvl).npcs)  {
    if (!
temp.npc.isinclass(CLASS)) continue;
    
//Update all Classes that are joined to kirko_test
    
temp.npc.trigger("Update"this);
  }


// Class name = kirko_test
// level npc
function onCreated()  { 
  
Kirko.update(this.level.name); 
}  

public function 
onUpdate() {
  
this.chat "Database Updated me";

__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.