From EDukeWiki
Revision as of 00:00, 24 September 2015 by Hendricks266 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A state is a block of code written outside of any actors or events, that can be called from within them. This is useful because it allows you to use the same code in multiple places without rewriting it.

Use the token defstate to create a state outside of other states, actors, or events. (State works too, but defstate is preferable if you use a syntax highlighter that can collapse blocks.) The token ends marks the end of the state.

defstate <name>
    // (state code...)

Calling a state within an actor is simply: state <name>

Example code:

define MYACTOR1 3585
define MYACTOR2 3586
define MYACTOR3 3587

defstate spawnblood
        guts JIBS6 12
        spawn BLOODPOOL

useractor notenemy MYACTOR1 2
    state spawnblood

useractor notenemy MYACTOR2 2
    state spawnblood

useractor notenemy MYACTOR3 2
    state spawnblood

Use break to exit a state before all of its code is finished executing.