Difference between revisions of "State exit"

From Second Life Wiki
Jump to navigation Jump to search
(The information is useful but it does not belong in the state_exit article, it should be in the touch articles and state article. Also, the user may not care about touch_end, so the advice is bad.)
(Change example to do state change from touch_end events, not touch_start)
Line 10: Line 10:
     state_entry()
     state_entry()
     {
     {
         llOwnerSay("in default state");
         llOwnerSay("Entering default state");
     }
     }
     touch_start(integer detected)
     touch_end(integer detected)
     {
     {
        // Note: NEVER do a state change from a touch_start event -
        // - this can result in a missed touch_start on re-entering this state
        // Here we do the state change safely from within touch_end
         state other;
         state other;
     }
     }
Line 26: Line 29:
     state_entry()
     state_entry()
     {
     {
         llOwnerSay("in state \"other\"");
         llOwnerSay("Entering state \"other\"");
     }
     }
     touch_start(integer detected)
     touch_end(integer detected)
     {
     {
         state default;
         state default;

Revision as of 05:54, 27 December 2012

Description

Event: state_exit( ){ ; }

Triggered on a qualifying state transition.


Caveats

  • Events queued during state_exit, are dumped before the next state is entered. use state_entry to avoid this, when possible. See state for further caveats.


Examples

<lsl>default {

   state_entry()
   {
       llOwnerSay("Entering default state");
   }
   touch_end(integer detected)
   {
       // Note: NEVER do a state change from a touch_start event -
       // - this can result in a missed touch_start on re-entering this state
       // Here we do the state change safely from within touch_end
       state other;
   }
   state_exit()
   {
       llOwnerSay("leaving default state");
   }

}

state other {

   state_entry()
   {
       llOwnerSay("Entering state \"other\"");
   }
   touch_end(integer detected)
   {
       state default;
   }
   state_exit()
   {
       llOwnerSay("leaving state \"other\"");
   }

}</lsl>

Notes

While the default state_entry is triggered on script reset, state_exit is not triggered prior to the reset.

Deep Notes

Signature

event void state_exit(  );