Triggered on any state transition and startup

Syntax

state_entry()

Event ID: 0.

Specification

Triggered

  1. Script save or adding to object
  2. State change
  3. On script reset, either by client or llResetScript/llResetOtherScript
  4. When the object is rezzed without a saved script status

Not Triggered

  1. When the object is rezzed with saved script status, not even on change of owner
  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

Functions

Deep notes

Issues