State
From Second Life Wiki
| LSL Portal | | | Functions | | | Events | | | Types | | | Operators | | | Constants | | | Flow Control | | | Script Library | | | Tutorials |
Contents |
In LSL, most scripts sit idle until they receive some input, or detect some change in their environment. At any moment, the script is in some state, and will react to events or inputs according to some scheme defined by the programmer. However, a script can also contain two or more different states, and react differently to events or inputs depending on what state it is in.
The main state is the default state. When a script is compiled, reset or loaded, this is the state it enters by default. After the default state definition can follow additional state definitions which the script may use to change how and which events are handled.
- The correct title of this article is state. The initial letter is shown capitalized due to technical restrictions.
state target { events }
target state definition. | ||||||||||
state target;
When a state target; is encountered at runtime, if the current state and the target state are different:
If target state is the same as the current state, no state change occurs nor do any of the side effects. | ||||||||||
Caveats
| ||||||||||
Examplesdefault { touch_start(integer a) { state hello; } } state hello { state_entry() { llOwnerSay("Hello"); state default; } state_exit() { llOwnerSay("Goodbye"); } } | ||||||||||

