Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (TipmyPip, Quad, alibaba, izorro), 545 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Why action and event handler pair ? #248728
01/28/09 19:56
01/28/09 19:56
Joined: Apr 2008
Posts: 437
dracula Offline OP
Senior Member
dracula  Offline OP
Senior Member

Joined: Apr 2008
Posts: 437
Why do we have to use an action and then a function to service the action event ? Why can't we just have an action or a function that does it both ?
I am assumming that we are using Lite-C code and not WED.

Thanks

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
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

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: Locoweed] #248806
01/29/09 08:29
01/29/09 08:29
Joined: Apr 2008
Posts: 437
dracula Offline OP
Senior Member
dracula  Offline OP
Senior Member

Joined: Apr 2008
Posts: 437

Hi Loco

So it's a choice not a requirement ?

Thanks

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 Offline
Expert
EvilSOB  Offline
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: EvilSOB] #248851
01/29/09 15:12
01/29/09 15:12
Joined: Apr 2008
Posts: 437
dracula Offline OP
Senior Member
dracula  Offline OP
Senior Member

Joined: Apr 2008
Posts: 437
Hi Evil.
Good point, thanks

drac.

Re: Why action and event handler pair ? [Re: dracula] #248855
01/29/09 15:55
01/29/09 15:55
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
and then you can have one event for several types of actions.

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 Offline
Expert
EvilSOB  Offline
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: EvilSOB] #249119
01/31/09 15:49
01/31/09 15:49
Joined: Sep 2003
Posts: 928
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 928
I am doing something like this in my code, it works this way:

function event_check()
{
my.skill55 = event_type;
}

action player()
{
...
my.event = event_check;
...
}

Now you can check skill55 in the entity while loop and check if it has changed. If yes, an event happened. You can then set skill55 back to 0 and wait for the next event.

Event_type directly checking in the action would not work because event_type is a global variables and changes all the time.

Re: Why action and event handler pair ? [Re: Spirit] #249120
01/31/09 15:52
01/31/09 15:52
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
and what if there are several events per frame?

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 Online
Senior Expert
Quad  Online
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
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1