Difference between revisions of "Touch end"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(13 intermediate revisions by 7 users not shown)
Line 4: Line 4:
|constants
|constants
|spec
|spec
|caveats
|caveats=* If a prim [[face]] has [[Navigating Shared Media|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=You can use numbers 0 through num_detected - 1 to get detected agent keys:
|examples=You can use numbers 0 through num_detected - 1 with the various llDetected... functions to get detected agent keys etc. For most purposes, it is adequate to bother only with the first detected toucher e.g. llDetectedKey(0).  It is rare (but not impossible) for num_detected to be other than 1.
<pre>
<source lang="lsl2">
float t;


default
default
Line 13: Line 12:
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
         t = llGetTime();
         llResetTime();
     }
     }
     touch_end(integer num_detected)
     touch_end(integer num_detected)
     {
     {
         llOwnerSay((string)(llGetTime() - t) + " seconds between touch_start and touch_end");
         llInstantMessage( llDetectedKey(0), "You held the mouse button down for " + (string) llGetTime() + " seconds");
     }
     }
}
}</source>
</pre>
 
|notes=*If using a touch to change states be careful about the touch_ event order. '''The best advice is NOT to do state changes from within touch_start.''' Use touch_end and do the state change there. Changing state from within touch_start can cause the next occurrence of THAT touch_start code to be missed. 
 
*On clicking a prim with touch events we trigger touch_start (on first contact), touch (during) and touch_end (as released).
 
|helpers
|helpers
|also_header
|also_header
Line 35: Line 38:
|cat1=Touch
|cat1=Touch
|cat2=Detected
|cat2=Detected
|cat3
|cat3=Grab
|cat4}}
|cat4=Passable
}}

Latest revision as of 21:07, 1 January 2016

Description

Event: touch_end( integer num_detected ){ ; }

Triggered when agent stops clicking on task

• integer num_detected

Caveats

  • 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

You can use numbers 0 through num_detected - 1 with the various llDetected... functions to get detected agent keys etc. For most purposes, it is adequate to bother only with the first detected toucher e.g. llDetectedKey(0). It is rare (but not impossible) for num_detected to be other 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");
    }
}

Notes

  • If using a touch to change states be careful about the touch_ event order. The best advice is NOT to do state changes from within touch_start. Use touch_end and do the state change there. Changing state from within touch_start can cause the next occurrence of THAT touch_start code to be missed.
  • On clicking a prim with touch events we trigger touch_start (on first contact), touch (during) and touch_end (as released).

See Also

Events

•  touch_start
•  touch

Functions

•  llPassTouches

Deep Notes

Signature

event void touch_end( integer num_detected );