State: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
No edit summary
No edit summary
Line 3: Line 3:
Syntax for state creation:
Syntax for state creation:


'''state''' <name> { state code } [[ends]]
'''state''' <name><br>
:(state code...)<br>
[[ends]]


<name> is the name of the state.
<name> is the name of the state.


{ state code } is the code executed within that state.
(state code...) is the code executed within that state.


[[ends]] denotes the end of a state.
[[ends]] denotes the end of a state.


 
Calling a state within an [[actor]] is simply: <code>'''state''' <name></code>
Calling a state within an [[actor]] is simply:
 
'''state''' <name>
 


Example code:
Example code:


<pre>
define MYACTOR1 3585
define MYACTOR1 3585
define MYACTOR2 3586
define MYACTOR2 3586
define MYACTOR3 3587
define MYACTOR3 3587
 
state spawnblood
state spawnblood
ifhitweapon
ifhitweapon
{
{
    guts JIBS6 12
    guts JIBS6 12
    spawn BLOODPOOL
    spawn BLOODPOOL
    killit
    killit
}
}
ends
ends
 
useractor notenemy MYACTOR1 2
useractor notenemy MYACTOR1 2
    state spawnblood
    state spawnblood
enda
enda
 
useractor notenemy MYACTOR2 2
useractor notenemy MYACTOR2 2
    state spawnblood
    state spawnblood
enda
enda
 
useractor notenemy MYACTOR3 2
useractor notenemy MYACTOR3 2
    state spawnblood
    state spawnblood
enda
enda
</pre>


Use [[break]] to exit a state before all of it's code is finished executing.
Use [[break]] to exit a state before all of its code is finished executing.


[[Category:Duke3D 1.3/1.5 commands]]
[[Category:Duke3D 1.3/1.5 commands]]

Revision as of 20:02, 5 March 2011

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.

Syntax for state creation:

state <name>

(state code...)

ends

<name> is the name of the state.

(state code...) is the code executed within that state.

ends denotes the end of a state.

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

Example code:

define MYACTOR1 3585
define MYACTOR2 3586
define MYACTOR3 3587

state spawnblood
ifhitweapon
{
    guts JIBS6 12
    spawn BLOODPOOL
    killit
}
ends

useractor notenemy MYACTOR1 2
    state spawnblood
enda

useractor notenemy MYACTOR2 2
    state spawnblood
enda

useractor notenemy MYACTOR3 2
    state spawnblood
enda

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