Difference between revisions of "Touch"

From Second Life Wiki
Jump to navigation Jump to search
m
(Added 2nd example)
Line 12: Line 12:
     }
     }
}</lsl>
}</lsl>
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.
<lsl>
default
{
    touch_start(integer num_detected)
    {
llResetTime();
    }
    touch(integer num_detected)
    {
if (llDetectedKey(0) == llGetOwner() && llGetTime() > 1.0)
{
    // The owner has touched this object for longer than 1 second
    // execute some special feature such as issuing a management dialog
    // ...
}
    }
    touch_end(integer num_detected)
    {
if (llGetTime() < 1.0)
{
    // The user did a normal quick click on the object
    // execute actions for normal clicks
    // ...
}
    }
}
</lsl>
|helpers
|helpers
|also_header
|also_header

Revision as of 17:06, 24 December 2012

Description

! Event: touch( integer num_detected ){ ; }

Triggered whilst an agent is clicking the task. It will continue to be triggered until the the prim/object is stopped being clicked (it triggers multiple times).

• integer num_detected

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
  • 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.


Examples

<lsl>default {

    touch(integer num_detected)
    {
         llOwnerSay("I am being touched by " + llDetectedName(0) + ".");
    }

}</lsl>

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.

<lsl> default {

   touch_start(integer num_detected)
   {

llResetTime();

   }
   touch(integer num_detected)
   {

if (llDetectedKey(0) == llGetOwner() && llGetTime() > 1.0) { // The owner has touched this object for longer than 1 second // execute some special feature such as issuing a management dialog // ... }

   }
   touch_end(integer num_detected)
   {

if (llGetTime() < 1.0) { // The user did a normal quick click on the object // execute actions for normal clicks // ... }

   }

} </lsl>

See Also

Events

•  touch_start
•  touch_end

Functions

•  llSetTouchText Set the pie menu's text for touch-action
•  llPassTouches Allows clicks captured by a child prim to be passed to the root as well

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   Server drops first touch event when a script returns to a state with a touch_start handler

Signature

event void touch( integer num_detected );