Skip to content
lsl.devlsl.devLSL Dev

touch_end

event
Event syntax
touch_end(
  1. integer num_detected// Total number of touching agents detected (usable with llDetected* functions).
) { … }

Triggered when an avatar stops touching the object. Passes num_detected, representing the number of touching agents.

Triggered when agent stops clicking on task

How to use
touch_end(integer num_detected)
{
}
  • 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.
  • Rigged mesh attachments do not support touch events, this is because you can steer your avatar/camera by click dragging your avatar body which is what the rigged mesh replaces. The only way to get a touch event on a rigged mesh attachment is via the right click context menu and clicking the “Touch” button.
You can use index 0 through (num_detected-1) with the various llDetected… functions to handle simultaneous touches at once.

For most purposes, it’s usually enough to handle just with the first toucher e.g. llDetectedKey(0). It is rare (but not impossible) for num_detected to be greater than 1.

default
{
touch_start(integer num_detected)
{
llResetTime();
}
touch_end(integer num_detected)
{
llInstantMessage(llDetectedKey(0), "You held the mouse button down for " + (string) llGetTime() + " seconds");
}
}
This next example demonstrates detecting when the owner of the object clicks-and-holds on the object for 1 second in order perhaps to access a management menu or similar, Normal brief clicks are distinguished.
5 collapsed lines
default
{
touch_start(integer num_detected)
{
llResetTime(); // Set llGetTime to 0
}
touch_end(integer num_detected)
{
// Check how much time elapsed since touch_start
if (llGetTime() <= 1.0)
{
// The user did a normal quick click on the object
// Execute actions for normal clicks...
}
else
{
// The owner has touched this object for longer than 1 second
// Execute some special feature such as issuing a management dialog...
}
}
}
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 Touch end, 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.