Difference between revisions of "State"

From Second Life Wiki
Jump to navigation Jump to search
(cleaned up bold and italics)
Line 8: Line 8:
{{LSL DefineRow|label|target|{{#var:p_jump_state_desc}}}}
{{LSL DefineRow|label|target|{{#var:p_jump_state_desc}}}}
{{!}}}<br/>
{{!}}}<br/>
When encountered at runtime, if the old state and the new state are different states:
When 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.
#Trigger [[state_exit]] in the current state if it exists and clear the event queue.
#Change state to '''target''', any [[listen]]s are unregistered.
#Change state to ''target'', any [[listen]]s are unregistered.
#Trigger [[state_entry]] in the new state if it exists.
#Trigger [[state_entry]] in the ''target'' state if it exists.
If '''target''' is the current state a state change does not happen nor does any of it's effects.
If ''target'' state is the same as the ''current'' state, no state changeoccurs nor do any of the effects.
}}{{#vardefine:constants_nb|
}}{{#vardefine:constants_nb|
<div id="box">
<div id="box">

Revision as of 12:16, 3 March 2007

The correct title of this article is state. The initial letter is shown capitalized due to technical restrictions.

state target;

state target;
• label target name of a state to run

When encountered at runtime, if the current state and the target state are different:

  1. Trigger state_exit in the current state if it exists and clear the event queue.
  2. Change state to target, any listens are unregistered.
  3. Trigger state_entry in the target state if it exists.

If target state is the same as the current state, no state changeoccurs nor do any of the effects.

state target{ events }

• label target state name
• event events one or more events

State definition.

Caveats

  • On state change all listens are released.

Examples

default
{
    touch_start(integer a)
    {
        state hello;
    }
}

state hello
{
    state_entry()
    {
        llOwnerSay("Hello");
        state default;
    }
    state_exit()
    {
        llOwnerSay("Goodbye");
    }
}

See Also

Keywords

•  jump
•  return

Events

•  state_entry
•  state_exit