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"
}