Category:Event manipulation: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Events are special occurences in the game engine, including specific key presses, display calls, etc.  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]].
Events are special occurrences in the game engine, including a tick in the game's 30 Hz state machine, key presses, display calls, etc.


Please see the [[EDuke32 event list]] for a complete list of all currently valid events in EDuke32.
== Usage ==
 
Used outside of all [[actor]]s and [[state]]s, '''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 mutator]]s.
 
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 ==
 
=== [[break]] ===
 
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.
 
=== [[return]] ===
 
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
endevent
appendevent EVENT_ENTERLEVEL
    return
endevent
appendevent EVENT_ENTERLEVEL
    echo 616
endevent
appendevent EVENT_ENTERLEVEL
    echo 616
endevent
 
This will print.
This will print.


[[Category:All commands]]
[[Category:All commands]]

Revision as of 18:19, 3 April 2015

Events are special occurrences in the game engine, including a tick in the game's 30 Hz state machine, key presses, display 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

break

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.

return

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
endevent

appendevent EVENT_ENTERLEVEL
    return
endevent

appendevent EVENT_ENTERLEVEL
    echo 616
endevent

appendevent EVENT_ENTERLEVEL
    echo 616
endevent
This will print.
This will print.

Subcategories

This category has only the following subcategory.

E

Pages in category "Event manipulation"

The following 10 pages are in this category, out of 10 total.