Touch start
From Second Life Wiki
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Contents |
Description
! Event: touch_start( integer num_detected ){ ; }| 2 | Event ID |
Triggered by the start of agent clicking on task
| • integer | num_detected | – | Number of agents detected touching during the last clockcycle |
Caveats
- When changing from a state that lacks a touch event into a state that has a touch event, the first touch will be dropped; this effects all three touch events (touch_start, touch, touch_end). See: SVC-3017[c]
- If a prim face has Shared Media enabled and the avatar's viewer supports this feature, LSL scripts will not detect touches on that face. Touches from older clients will be detected.
Important Issues
~ All Issues ~ Search JIRA for related Bugs| | | SVC-3017 | [A, C] | Server drops first touch event when a script returns to a state with a touch_start handler |
Examples
You can use numbers 0 through num_detected - 1 to get detected agent keys:
default { touch_start(integer num_detected) { integer i = 0; for(; i<num_detected; ++i) llWhisper(0, "Touched by " + llKey2Name(llDetectedKey(i))); } }
If there is any state change in touch_start event and you click on a prim and release before the state is changed, succeeding touch and touch_end events will be discarded from the event queue before entering the new state. It means no touch_* event will occur in this new state until you touch it again. If you drop this script into any prim and click it, you will only see the message "You just started touching me so I'm going to the other state...". When you click it again, you will only see the message "The touch that brought you here just ended so I'm going back to default...".
default { touch_start(integer nd) { llSay(0, "You just started touching me so I'm going to the other state..."); state other; } } state other { touch_end(integer nd) { llSay(0, "The touch that brought you here just ended so I'm going back to default..."); state default; } }
Notes
- If using a touch to change states be careful about the touch_ event order. On clicking a prim with touch events we trigger touch_start (as), touch (during) and touch_end (as released). The touch_ chain will remain intact until either touch_end is triggered or a new touch_start. If however the script is reset (although there is some doubt as far as this is concerned (see SVC-3017[c] for more details) the chain will be cleared. If the script is taken into inventory, deleted or the like, the touch_chain is cleared too. It is not certain whether the behavior is truly a bug or expected.
See Also
Events
| • | touch | |||
| • | touch_end |
Functions
| • | llSetTouchText | |||
| • | llPassTouches | |||
| • | LlDetectedTouchFace | |||
| • | LlDetectedTouchST | |||
| • | LlDetectedTouchUV | |||
| • | LlDetectedTouchPos | |||
| • | LlDetectedTouchNormal | |||
| • | LlDetectedTouchBinormal |
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.

