Difference between revisions of "State entry"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Event
{{Issues/SVC-3379}}{{LSL_Event
|event_id=0|event_delay|event=state_entry
|event_id=0|event_delay|event=state_entry
|event_desc=Triggered on any state transition and startup
|event_desc=Triggered on any state transition and startup
Line 5: Line 5:
|spec=
|spec=
=== Triggered ===
=== Triggered ===
#When rezzing a {{HoverText|script|in an object}} that does not have a saved state.
#Script save or adding to object
#State change
#*A [[state_exit]] is triggered in the old state and the [[state_entry]] is triggered in the new state. All other events in the queue are lost as a result of the state change.
#On script reset, either by client or [[llResetScript]]/[[llResetOtherScript]]
#When the object is rezzed ''without'' a saved script status
#*If it was a copy taken from inworld
#*If it was a copy taken from inworld
#*If the event had not been triggered due to no-script land.
#*If the event had not been triggered due to no-script land.
#On script reset, either by client or [[llResetScript]]/[[llResetOtherScript]]
#State change
#*A [[state_exit]] is triggered in the old state and the [[state_entry]] is triggered in the new state. All other events in the queue are lost as result of the state change.


=== Not Triggered ===
=== Not Triggered ===
#When the object is rezzed (with saved script state)
#When the object is rezzed ''with'' saved script status, not even on change of owner
#*Use [[on_rez]] event in this situation
#*Use [[on_rez]] event in this situation
#When the task moves to another SIM, nor on SIM restart
|caveats
|caveats
|examples
|examples=
<source lang="lsl2">
default
{
    state_entry()
    {
        llSay(0,
            "You either just saved the script after editing it"
            + "\nand/or the script (re)entered the default state.");
        llSetText("Click to change states", <1.0, 1.0, 1.0>, 1.0);
    }
    touch_end(integer num_detected)
    {
        // Note: NEVER do a state change from within a touch_start event -
        // - that can lead to the next touch_start on return to this state to be missed.
        // Here we do the state change safely, from within touch_end
        state two;
    }
    state_exit()
    {
        llSay(0, "The script leaves the default state.");
    }
}
state two
{
    state_entry()
    {
        llSay(0, "The script entered state 'two'");
        state default;
    }
    state_exit()
    {
        llSay(0, "The script leaves state 'two'");
    }
}
</source>
|helpers
|helpers
|also_header
|also_header
|also_events
|also_events={{LSL DefineRow||[[on_rez]]|Triggered when the object is rezzed}}
|also_functions
{{LSL DefineRow||[[state_exit]]|Triggered when the state is exited at state change}}
|also_functions={{LSL DefineRow||[[llResetScript]]|Resets the script}}
{{LSL DefineRow||[[llResetOtherScript]]|Resets another script in the prim}}
{{LSL DefineRow||[[llGetStartParameter]]|The [[on_rez]] parameter (or [[llRemoteLoadScriptPin]] parameter)}}
|also_articles
|also_articles
|also_footer
|also_footer
Line 27: Line 72:
|deprecated
|deprecated
|cat1=Script
|cat1=Script
|cat2
|cat2=State
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 01:08, 22 January 2015

Description

Event: state_entry( ){ ; }

Triggered on any state transition and startup


Specification

Triggered

  1. Script save or adding to object
  2. State change
    • A state_exit is triggered in the old state and the state_entry is triggered in the new state. All other events in the queue are lost as a result of the state change.
  3. On script reset, either by client or llResetScript/llResetOtherScript
  4. When the object is rezzed without a saved script status
    • If it was a copy taken from inworld
    • If the event had not been triggered due to no-script land.

Not Triggered

  1. When the object is rezzed with saved script status, not even on change of owner
    • Use on_rez event in this situation
  2. When the task moves to another SIM, nor on SIM restart

Examples

default
{
    state_entry()
    {
        llSay(0,
            "You either just saved the script after editing it"
            + "\nand/or the script (re)entered the default state.");
 
        llSetText("Click to change states", <1.0, 1.0, 1.0>, 1.0);
    }
 
    touch_end(integer num_detected)
    {
        // Note: NEVER do a state change from within a touch_start event -
        // - that can lead to the next touch_start on return to this state to be missed.
        // Here we do the state change safely, from within touch_end
        state two;
    }
 
    state_exit()
    {
        llSay(0, "The script leaves the default state.");
    }
}
 
state two
{
    state_entry()
    {
        llSay(0, "The script entered state 'two'");
        state default;
    }
 
    state_exit()
    {
        llSay(0, "The script leaves state 'two'");
    }
}

See Also

Events

•  on_rez Triggered when the object is rezzed
•  state_exit Triggered when the state is exited at state change

Functions

•  llResetScript Resets the script
•  llResetOtherScript Resets another script in the prim
•  llGetStartParameter The on_rez parameter (or llRemoteLoadScriptPin parameter)

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   changing to same state triggers state_entry in mono compiled script

Signature

event void state_entry(  );