Skip to content
lsl.devlsl.devLSL Dev

State entry

Looking for the current API? Open the state_entry reference →

Wiki description

Triggered on any state transition and startup

Specification

Triggered

  • 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 the event had not been triggered due to no-script land.

Not Triggered

  • When the object is rezzed with saved script status, not even on change of owner
    • Use on_rez event in this situation
  • 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: functions

See also: events

Known issues

Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from State entry, by Linden Research, Inc. and contributing residents.View contributors and history.

Built from these wiki pages, as imported:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.