Category:Event manipulation
Events are special occurrences in the game engine. They allow modifications to inject custom code outside of actor definitions, which is executed before or after the corresponding game event.
Some events also allows the outcome of the occurrence to be changed. For instance, for EVENT_CHANGEMENU, one can alter the destination of a specific menu transition.
Example events include the passing of tic time in the game's 30 Hz state machine, player keypresses, display rendering calls, etc.
Usage
Used outside of all actors and states, onevent and appendevent define a special block of CON code to be executed when a specific event happens in the game code. endevent is used to end the block.
gamevar MYMEDPACK 100 1 onevent EVENT_TURNAROUND palfrom 32 0 0 32 addphealth 5 subvar MYMEDPACK 5 setvar RETURN -1 endevent
The hardcoded portion of many events can be modified by altering the special gamevar RETURN in a way specific to each event.
Events are also the only of the three CON entry points (the other two being actor and eventloadactor code) that may recurse, for example through EVENT_EGS, EVENT_SPAWN or EVENT_KILLIT.
Please see the EDuke32 event list for a complete list of all events available.
Event Chaining
The keyword appendevent performs the same function as onevent, but with the difference that successive definitions of events are prepended with onevent, and appended with appendevent. This is useful for keeping your CONs organized, as well as to facilitate CON mutators.
For example:
definequote 666 Placeholder. appendevent EVENT_ENTERLEVEL redefinequote 666 0 echo 666 endevent appendevent EVENT_ENTERLEVEL redefinequote 666 1 echo 666 endevent onevent EVENT_ENTERLEVEL redefinequote 666 -1 echo 666 endevent appendevent EVENT_ENTERLEVEL redefinequote 666 2 echo 666 endevent onevent EVENT_ENTERLEVEL redefinequote 666 -2 echo 666 endevent
-2 -1 0 1 2
The two commands are identical when defining the first instance of an event found when the game parses the CONs.
Terminating Execution
The break keyword can be used to terminate the current event block.
definequote 666 This will print. definequote 616 This will never print. appendevent EVENT_ENTERLEVEL echo 666 break echo 616 endevent appendevent EVENT_ENTERLEVEL echo 666 break echo 616 endevent appendevent EVENT_ENTERLEVEL echo 666 break echo 616 endevent
This will print. This will print. This will print.
The return keyword will prevent any further execution of the event in the block chain. Use with caution!
definequote 666 This will print. definequote 616 This will never print. appendevent EVENT_ENTERLEVEL echo 666 endevent appendevent EVENT_ENTERLEVEL echo 666 return echo 616 endevent appendevent EVENT_ENTERLEVEL echo 616 endevent
This will print. This will print.
The command also functions from states.
definequote 666 This will print. definequote 616 This will never print. state example_state return ends appendevent EVENT_ENTERLEVEL echo 666 endevent appendevent EVENT_ENTERLEVEL echo 666 state example_state echo 616 endevent appendevent EVENT_ENTERLEVEL echo 616 endevent
This will print. This will print.
Pages in category "Event manipulation"
The following 10 pages are in this category, out of 10 total.