Category:Event manipulation - EDukeWiki

Help

# Category:Event manipulation

From EDukeWiki

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
        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.

## Subcategories

This category has only the following subcategory.

### E

- ► Events‎ (94 P)

## Pages in category "Event manipulation"

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

### A

- Appendevent

### B

- Break

### E

- Endevent
- Event list

### O

- Onevent

### R

- Return

### U

- Unsynchronized events

Retrieved from "http://wiki.eduke32.com/w/index.php?title=Category:Event_manipulation&oldid=12185"
Category:

- All commands