View Single Post
  #2  
Old 08-28-2017, 04:10 AM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko is a jewel in the roughKirko is a jewel in the rough
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