Difference between revisions of "State entry"

From Second Life Wiki
Jump to navigation Jump to search
m (Undo revision 259122 by Strife Onizuka (Talk) stupidity)
m (changed example script)
Line 17: Line 17:
#*Use [[on_rez]] event in this situation
#*Use [[on_rez]] event in this situation
|caveats
|caveats
|examples=<lsl>default
|examples=
<lsl>
default
{
{
     state_entry()
     state_entry()
     {
     {
         llSay(0, "Hello, Avatar!");
        // PUBLIC_CHANNEL has the integer value 0
         llSay(PUBLIC_CHANNEL,
            "You either just saved the script after editing it"
            + "\nand/or the script (re)entered the default state.");
 
        // white and opaque text
        llSetText("Click to change states", <1.0, 1.0, 1.0>, (float)TRUE);
     }
     }
}</lsl>
 
    touch_start(integer num_detected)
    {
        state other;
    }
}
 
state other
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "The script entered the other state.");
        state default;
    }
}
</lsl>
|helpers
|helpers
|also_header
|also_header

Revision as of 12:33, 5 October 2012

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
    • Use on_rez event in this situation

Caveats


Examples

<lsl> default {

   state_entry()
   {
       // PUBLIC_CHANNEL has the integer value 0
       llSay(PUBLIC_CHANNEL,
           "You either just saved the script after editing it"
           + "\nand/or the script (re)entered the default state.");
       // white and opaque text
       llSetText("Click to change states", <1.0, 1.0, 1.0>, (float)TRUE);
   }
   touch_start(integer num_detected)
   {
       state other;
   }

}

state other {

   state_entry()
   {
       llSay(PUBLIC_CHANNEL, "The script entered the other state.");
       state default;
   }

} </lsl>

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(  );