Skip to content
lsl.devlsl.devLSL Dev

state_exit

event
Event syntax
state_exit() { … }

Triggered when the state command is used to transition out of the current state. Handled before entering the new state's state_entry.

Triggered on a qualifying state transition.

How to use
state_exit()
{
}
  • 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.
Example 1
11 collapsed lines
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");
}
}
8 collapsed lines
state other
{
state_entry()
{
llOwnerSay("Entering state \"other\"");
}
touch_end(integer detected)
{
state default;
}
state_exit()
{
llOwnerSay("leaving state \"other\"");
}
}

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

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 exit, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

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.