Difference between revisions of "State"

From Second Life Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
{{LSL Header|
{{LSL Header|
}}{{#vardefine:name|jump
}}{{#vardefine:name|state
}}{{#vardefine:p_jump_target_desc|Name of a label inside the same leg of the scope hierarchy tree
}}{{#vardefine:p_jump_state_desc|name of a state to run
}}{{#vardefine:p_label_target_desc|A label that can be jumped to if the jump is in the same scope or child scope.
}}{{#vardefine:p_label_state_desc|state name
}}{{#vardefine:header_title|jump {{LSL Param|jump_target|target}};
}}{{#vardefine:p_events_desc|one or more events
}}{{#vardefine:header_title|state {{LSL Param|jump_state|target}};
}}{{#vardefine:header_text|{{{!}}
}}{{#vardefine:header_text|{{{!}}
{{LSL DefineRow|label|target|{{#var:p_jump_target_desc}}}}
{{LSL DefineRow|label|target|{{#var:p_jump_state_desc}}}}
{{!}}}
{{!}}}
Causes the script to exit the current state (and triggering the [[state_exit]] if it exists) and enter the state '''target'''. If the old state and the new state are the same state, neither the [[state_entry]] or [[state_exit]] are queued.
}}{{#vardefine:constants_nb|
}}{{#vardefine:constants_nb|
<div id="box">
<div id="box">
<h2>@{{LSL Param|label_target|target}};</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_target_desc}}}}
{{LSL DefineRow|label|target|{{#var:p_label_state_desc}}}}
{{LSL DefineRow|event|events|{{#var:p_events_desc}}}}
{{!}}}
{{!}}}
State definition.
</div>
</div>
</div>
</div>
}}{{#vardefine:examples|
}}{{#vardefine:examples|
<pre>
<pre>
integer a = 5;
state hello
jump over;
{
@in;
    state_entry()
a = 6;
    {
@over;
        llOwnerSay("Hello");
llOwnerSay((string)a);
        state default;
if(a < 6)
    }
     jump in;
    state_exit()
//script will say 5 and then 6
    {
        llOwnerSay("Goodbye");
    }
}
 
default
{
    touch_start(integer a)
     {
        state hello;
    }
}
</pre>
</pre>
}}{{#vardefine:notes|
}}{{#vardefine:notes|
Line 33: Line 48:
}}{{#vardefine:also_header|<h3>Keywords</h3>
}}{{#vardefine:also_header|<h3>Keywords</h3>
{{{!}}
{{{!}}
{{LSL DefineRow||[[jump]]|}}
{{LSL DefineRow||[[return]]|}}
{{LSL DefineRow||[[return]]|}}
{{LSL DefineRow||[[state]]|}}
{{!}}}
{{!}}}
}}{{#vardefine:also_footer|
}}{{#vardefine:also_footer|

Revision as of 14:22, 2 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

Causes the script to exit the current state (and triggering the state_exit if it exists) and enter the state target. If the old state and the new state are the same state, neither the state_entry or state_exit are queued.

state target{ events }

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

State definition.

Examples

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

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

See Also

Keywords

•  jump
•  return