Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   How to trigger same function accross multiple classes? (https://forums.graalonline.com/forums/showthread.php?t=72883)

Inverness 03-17-2007 06:51 AM

How to trigger same function accross multiple classes?
 
For the new mud system I'm working on its imperative that I be able to trigger same the function across multiple classes, preferably in the order the classes are joined to the object.

For example, I have Object, and I join ClassA and ClassB to Object, I must have a way of triggering the Created event in ClassA then ClassB as they have their own things that need to be done.

Angel_Light 03-17-2007 06:56 AM

I had to do this awhile back and Hikaru helped me with it
I'd Put this in a class and made the other class trigger each other.

PHP Code:

this.join("class");
class::
FunctionInClass(); 

I did the above on serverside so I'm not sure if it would work on the clientside part of the class.
Then whenever I need the function I can simply use the function

PHP Code:

FunctionInClassvar1var2); 


Inverness 03-17-2007 07:14 AM

Bah, when I tried that the first time I never worked, and now it magically does, how irritating.

Angel_Light 03-17-2007 07:16 AM

Heh, well glad to see it's working for you. ^_^

Inverness 03-17-2007 07:25 AM

I have problem now, how to make it so it only calls the function in the object and not classes?

Angel_Light 03-17-2007 07:32 AM

can you attach vars to the function and if whatever var equals foo it calls in that area specifically?

Inverness 03-17-2007 10:37 AM

...
Why didn't I think of that >_>
That is good idea, but I was hoping to not have to do that :(

I suppose what I'll do is have the functions named differently for each class, like <classname>_onCreated() and then this_onCreated() for the base object or something, it would be about the same as doing classname::functionname() and I'll just make a function to call each of those.

We'd have the normal onCreated() event block that would have triggerall("Created", params) that would trigger the blocks that actually do something, starting with the this_onCreated() event and moving through class list.

So any time a normal event is triggered it would trigger the 'multi-event' as a result.


All times are GMT +2. The time now is 10:34 AM.

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