LSL is an event-driven language. Literally, scripts are divided into blocks of code that are triggered when a certain event happens. Scripts can provide event handlers, like moving_end or touch_start. If a script provides an event handler, and an event of this type occurs, thesimulator will add this event to the script’s event queue.
The script’s event handlers will then be called in the order the events are queued in (FIFO). According to Cory Linden, the event queue can hold up to 64 events. If the event queue is filled, it will silently drop any new events. Remember: LSL is not multi-threaded. Only one event will be run at a time; events cannot interupt each other. There is no way to interact with the event queue directly.
Changing states clears the event queue. Different states can have different event handlers. Be wary of bugs though. For instance, when an event handler is called, all of the arguments for that event handler are passed by value, and thus placed on the script’s stack. If a script has insufficient memory to hold all of the arguments, the script is halted with a “stack/heap collision” error and no code in the event handler will run.
Unlike functions, it’s not possible for scripters to create our own custom event handlers. If you need to check whether or not something has occurred, and it’s not covered by an existing event handler, you’ll need to use the timer() event.
The function llMinEventDelay may be of some use in coordinating events.
|at_rot_target||when a rotational target set with llRotTarget is reached|
|at_target||when a target set with llTarget is reached|
|attach||when an object attaches or detaches from agent|
|changed||when certain aspects of the object are changed (inventory, color, shape, scale, texture, link, ownership)|
|collision||while task is colliding with another task|
|collision_end||when task stops colliding with another task, or stops being penetrated while llVolumeDetect is set|
|collision_start||when task starts colliding with another task, or starts being penetrated while llVolumeDetect is set|
|control||when one of the controls taken with llTakeControls is pressed/held/released|
|dataserver||when task receives asynchronous data|
|when task receives email|
|http_response||when task receives response to request made with llHTTPRequest|
|http_request||when task receives response to request made with an external HTTP Request|
|land_collision||while task is colliding with land|
|land_collision_end||when task stops colliding with land|
|land_collision_start||when task starts colliding with land|
|link_message||when task receives a link message sent via llMessageLinked|
|listen||when task is within hearing range of chat matching the critera set in llListen|
|money||when money is given to task|
|moving_end||when task stops moving or when task exits a sim.|
|moving_start||when task begins moving or when task enters a sim.|
|no_sensor||when a call to llSensor or llSensorRepeat results in no targets sensed|
|not_at_rot_target||when a rotational target set with llRotTarget is not yet reached|
|not_at_target||when a target set with llTarget is not yet reached|
|object_rez||when task rezzes another task using llRezObject|
|on_rez||when task is rezzed (from inventory or another task, includes attaching directly from inventory)|
|remote_data||any kind of XML-RPC communication|
|run_time_permissions||when an agent grants run-time permissions to task that were requested via llRequestPermissions|
|sensor||Result of llSensor or llSensorRepeat functions|
|state_entry||on any transition into the state and on startup|
|state_exit||on any state transition out of the state|
|timer||in intervals set by llSetTimerEvent|
|touch||while agent clicks on task|
|touch_start||when agent starts clicking on task|
|touch_end||when agent stops clicking on task|
|transaction_result||fired by llTransferLindenDollars|
Q: Wait, what’s a “task”?
Q: How do I get input from one event and act on that in another?
Q: How do I know which event is going to be triggered, and in what order? This is complicated!
Q: Okay, but what about other events? How do I know when they’ll be triggered?
Q: What’s the different between an “event” and an “event handler”? I’ve seen both terms used, but they seem to both apply to the same thing.
Q: Can events interrupt each other?
Q: Why is there no event handler for “Release Keys” button?
Credit to: Lslwiki.net (not working) with changes made for brevity and clarity.