Events
Events are a special type of function. Events are the only functions that are allowed inside of a state. Event functions are not usually called by other functions. Event functions are called by Second Life itself. Second Life calls an event function when something happens that might be of interest to the script. Usually events are called because of some interaction on the scripted object either by the Second Life world or another use.
Events have very specific names. This name tells Second Life what event type this function is designed to handle. So far this chapter has used two specific events: touch_start and state_entry.
The touch_start event is called by Second Life whenever an avatar touches an object. If you need to know when the avatar has simply clicked an object, touch_start can be used. There is also a touch_end. The touch_end event is used when you need to track how long the avatar has touched an object.
The state_entry event function is called whenever a new state is entered. When multiple states are created, each state will usually have a state_entry event function to setup for that state.
There are many more event types in Second Life than were covered here. Events will be covered in much greater detail in Chapter 7.












