Difference between revisions of "State"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
}}{{#vardefine:p_label_state_desc|state name | }}{{#vardefine:p_label_state_desc|state name | ||
}}{{#vardefine:p_events_desc|one or more {{LSLGC|Events|events}} | }}{{#vardefine:p_events_desc|one or more {{LSLGC|Events|events}} | ||
}}{{#vardefine:header_title| | }}{{#vardefine:header_title|default { {{LSL Param|events}} } | ||
}}{{#vardefine:header_text|{{{!}} | }}{{#vardefine:header_text|{{{!}} | ||
{{LSL DefineRow| | {{LSL DefineRow|event|events|{{#var:p_events_desc}}}} | ||
{{!}}} | {{!}}} | ||
The default state definition. | |||
}}{{#vardefine:constants_nb| | }}{{#vardefine:constants_nb| | ||
<div id="box"> | <div id="box"> | ||
<h2> | <h2>state {{LSL Param|label_state|target}} { {{LSL Param|events}} }</h2> | ||
<div style="padding: 0.5em"> | <div style="padding: 0.5em"> | ||
{{{!}} | {{{!}} | ||
{{LSL DefineRow|label|target|{{#var:p_label_state_desc}}}} | |||
{{LSL DefineRow|event|events|{{#var:p_events_desc}}}} | {{LSL DefineRow|event|events|{{#var:p_events_desc}}}} | ||
{{!}}} | {{!}}} | ||
'''target''' state definition. | |||
</div> | </div> | ||
</div> | </div> | ||
Line 26: | Line 23: | ||
{{!}} | {{!}} | ||
<div id="box"> | <div id="box"> | ||
<h2>state {{LSL Param| | <h2>state {{LSL Param|jump_state|target}};</h2> | ||
<div style="padding: 0.5em"> | <div style="padding: 0.5em"> | ||
{{{!}} | {{{!}} | ||
{{LSL DefineRow|label|target|{{#var: | {{LSL DefineRow|label|target|{{#var:p_jump_state_desc}}}} | ||
{{ | {{!}}}<br/> | ||
When a ''state target;'' is encountered at runtime, if the ''current'' state and the ''target'' state are different: | |||
'''target''' state | #Trigger [[state_exit]] in the current state if it exists and clear the event queue. | ||
#Change state to ''target'', any [[listen]]s are unregistered. | |||
#Trigger [[state_entry]] in the ''target'' state if it exists. | |||
If ''target'' state is the same as the ''current'' state, no state change occurs nor do any of the side effects. | |||
</div> | </div> | ||
</div> | </div> | ||
Line 62: | Line 62: | ||
**All [[listen]]s are released. | **All [[listen]]s are released. | ||
**The event queue is cleared | **The event queue is cleared | ||
*The | *The ''default'' state must be defined before all others. | ||
}}{{#vardefine:helpers| | }}{{#vardefine:helpers| | ||
}}{{#vardefine:also_header|<h3>Keywords</h3> | }}{{#vardefine:also_header|<h3>Keywords</h3> |
Revision as of 21:48, 5 March 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
- The correct title of this article is state. The initial letter is shown capitalized due to technical restrictions.
default { events }
default { events }• event | events | – | one or more events |
The default state definition.
state target { events }
• label | target | – | state name | |
• event | events | – | one or more events |
target state definition.
|- |
state target;
• label | target | – | name of a state to run |
When a state target; is encountered at runtime, if the current state and the target state are different:
- Trigger state_exit in the current state if it exists and clear the event queue.
- Change state to target, any listens are unregistered.
- Trigger state_entry in the target state if it exists.
If target state is the same as the current state, no state change occurs nor do any of the side effects.
Caveats
- On state change:
- All listens are released.
- The event queue is cleared
- The default state must be defined before all others.
Examples
default { touch_start(integer a) { state hello; } } state hello { state_entry() { llOwnerSay("Hello"); state default; } state_exit() { llOwnerSay("Goodbye"); } }
See Also