From EDukeWiki
Jump to: navigation, search

A return command is similar to break in that it stops code after the return from executing and thus can be used to exit a state early. However, a return propagates along a call chain of states and terminates the execution of the innermost event or actor code. Thus, when the following code snippet is run, only quote 125 ("SPAWNED HEAVYHBOMB") is displayed.

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

state teststate1
    userquote 127

onevent EVENT_EGS
    ifactor HEAVYHBOMB
        state teststate1  // after teststate1's return, return from EVENT_EGS!
        userquote 126

    ifvare THISACTOR 0
        // the concrete actor is irrelevant, only placeholder
        spawn HEAVYHBOMB  // --> EVENT_EGS
        userquote 125

Replacing the return by a break in the above example would lead to quotes 126 and 125 being displayed (in that order) at run time.