Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Joining Classes (https://forums.graalonline.com/forums/showthread.php?t=62815)

jake13jake 12-16-2005 10:26 PM

Joining Classes
 
When you use the join() function to join a class, what is the precedence of event handlers? Can event handlers share the same events with the NPC?

ex.
let's say this is class "class":
function onCreated() {
setshape(1,32,32);
}

and call this an npc:
join("class");
function onCreated() {
setshape(1,64,64);
}

would the class event handler be called and then the npc event handler? Would they both have the capacity to be called? I'm just wondering because I just decided to propose an action handling structure for Classic, but it would probably encounter this a lot.

ZeLpH_MyStiK 12-17-2005 12:49 AM

You can just test this yourself.

jake13jake 12-17-2005 01:41 AM

that doesn't mean there's more to it that I can't test for.

ZeLpH_MyStiK 12-17-2005 03:25 AM

Quote:

Originally Posted by jake13jake
that doesn't mean there's more to it that I can't test for.

That made no sense whatsoever.

jake13jake 12-17-2005 03:27 AM

Quote:

Originally Posted by ZeLpH_MyStiK
That made no sense whatsoever.

Not really, I just hate the lack of commands documentation.

ZeLpH_MyStiK 12-17-2005 06:53 AM

Quote:

Originally Posted by jake13jake
Not really, I just hate the lack of commands documentation.

Now that I agree with. However, you must keep in mind that GS2 is still under development and things are being changed around all the time, so it's kind of hard to make a documentation for it.

Admins 12-17-2005 05:13 PM

The onCreated() part is called for each joined class, if you pre-join a class (put the join outside of any function) or you join a class in an onCreated() function.
Other events only choose the first event handler they find. That makes it possible to overwrite the event handler of a class. If you overwrite the event handler and want still that the original event handler is executed, call classname::function yourself, like
PHP Code:

function onCreated() {
  
join("myitems");
  
// no need to call myitems::onCreated() here since it is executed anyway
}
function 
onPlayerEnters() {
  echo(
"player enters!");
  
myitems::onPlayerEnters();


We should may be add a wiki page for the Graal script classes.

jake13jake 12-18-2005 12:50 AM

Thank you Stefan <3!!!!!!!!
That's a lot more information than I thought was behind it.

ApothiX 12-18-2005 06:24 AM

:o Stefan supports the wiki?

Admins 12-20-2005 07:33 PM

Yes I have added a lot of text there, but someone needs to remind Loriel to change the licensing thing


All times are GMT +2. The time now is 04:16 PM.

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