|
|
Re: Why action and event handler pair ?
[Re: dracula]
#248760
01/28/09 22:17
01/28/09 22:17
|
Joined: Oct 2002
Posts: 2,256 Oz
Locoweed
Expert
|
Expert
Joined: Oct 2002
Posts: 2,256
Oz
|
Hiya dracula,
In event driven source it is better to have the event code seperate from normal code. It's just more efficient so you can keep all your event driven code in a place where you know that it is actually event driven.
It kind of just makes sense to have it that way.
Professional A8.30 Spoils of War - East Coast Games
|
|
|
Re: Why action and event handler pair ?
[Re: dracula]
#248812
01/29/09 08:57
01/29/09 08:57
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Thats right, but its easier to manage with it split in two.
Another way that may suit you better is to create your entity, then set its emask=ENABLE_flags and event=somefunction in the function thats doing the creating. That way, IF your entity has an action, it doesnt have anything to do with processing the event, that will ALL be handled by the "somefuntion" event handler. You could also set or change the Entitys emask=ENABLE_flags and event=somefunction settings at a later time, it doesnt have to be done by an action, or at creation time.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Why action and event handler pair ?
[Re: Joey]
#248858
01/29/09 16:51
01/29/09 16:51
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Another way I just thought of, but have never actually tried, is to set the emask=ENABLE_flags and event=NULL in an entities action.
Then you can check the "event_type" inside the actions own loop (after any c_move()s etc) rather than having an external function to need to kick in and take over.
This idea has not been tested, but in theory it should work.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Why action and event handler pair ?
[Re: Joey]
#249122
01/31/09 15:54
01/31/09 15:54
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
i guess it triggers event function more than once in this case.
and you can already check which one is triggered the function by looking at event_type.
3333333333
|
|
|
|