Terminate

From EDukeWiki
Jump to navigation Jump to search

The terminate command is used to exit the current state early, without propagating down the entire call chain.

By contrast, the return command propagates along a call chain of states and completely terminates the execution of the innermost event or actor code.

For clarity, this should be used instead of the break command.

Examples

When the following code snippet is run, quote 125 ("SPAWNED HEAVYHBOMB") and quote 126 ("RAN EVENT_EGS") are displayed, but not quote 127 ("RAN TEST STATE").

definequote 125 SPAWNED HEAVYHBOMB
definequote 126 RAN EVENT_EGS
definequote 127 RAN TEST STATE

state teststate1
    terminate
    userquote 127
ends

onevent EVENT_EGS
    ifactor HEAVYHBOMB
    {
        state teststate1
        userquote 126
    }
endevent

onevent EVENT_LOADACTOR
    ifvare THISACTOR 0
    {
        // the concrete actor is irrelevant, only placeholder
        spawn HEAVYHBOMB  // --> EVENT_EGS
        userquote 125
    }
endevent