Terminate: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Created page with "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") a..."
 
No edit summary
 
Line 35: Line 35:
  '''endevent'''
  '''endevent'''


 
[[Category:EDuke32 specific commands]]
[[Category:Event manipulation]]
[[Category:Event manipulation]]

Latest revision as of 04:24, 7 January 2024

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