Difference between revisions of "LlDetectedTouchFace"

From Second Life Wiki
Jump to navigation Jump to search
m
(Added simple but very useful script to better focus on the essentials)
Line 14: Line 14:
** The event triggered is not a {{LSLGC|Touch|touch}} event.
** The event triggered is not a {{LSLGC|Touch|touch}} event.
|examples=
|examples=
<lsl>
// This is the essential script to drop in a prim when you need to ascertain the number of a face or faces
// Touch the prim surfaces to learn their face numbers, which you can then use in other scripts for texturing, colouring etc.
default
{
    touch_start(integer num_detected)
    {
        integer face = llDetectedTouchFace(0);
        if (face == TOUCH_INVALID_FACE)
            llSay(0, "The touched face could not be determined");
        else
            llSay(0, "You touched face number " + (string) face);
    }
}
</lsl>
<lsl>
<lsl>
default
default

Revision as of 05:48, 26 December 2012

Summary

Function: integer llDetectedTouchFace( integer index );

Returns an integer that is the index of the face the avatar clicked on.

• integer index Index of detection information

index does not support negative indexes. For the touch category of events only. The prim that was touched may not be the prim receiving the event, use llDetectedLinkNumber to check for this; likewise you can use llDetectedTouchFace to determine which face was touched.

Caveats

  • If index is out of bounds the script continues to execute without an error message.
  • TOUCH_INVALID_FACE is returned when...
    • The avatar's viewer does not support face touch detection.
    • The touch has moved off the surface of the prim.
    • The event triggered is not a touch event.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl> // This is the essential script to drop in a prim when you need to ascertain the number of a face or faces // Touch the prim surfaces to learn their face numbers, which you can then use in other scripts for texturing, colouring etc. default {

   touch_start(integer num_detected)
   {
       integer face = llDetectedTouchFace(0);
       if (face == TOUCH_INVALID_FACE)
           llSay(0, "The touched face could not be determined");
       else
           llSay(0, "You touched face number " + (string) face);
   }

} </lsl>

<lsl> default {

   touch_start(integer num_detected)
   {
       integer touchedFace = llDetectedTouchFace(0);
       // PUBLIC_CHANNEL has the integer value 0
       if (touchedFace == -1)
           llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
       else
       {
           // store the original color
           vector originalColor = llGetColor(touchedFace);
           // color detected face white
           llSetColor(<1.0, 1.0, 1.0>, touchedFace);
           llSleep(0.1);
           // color detected face black
           // ZERO_VECTOR has the vector value <0.0, 0.0, 0.0>
           llSetColor(ZERO_VECTOR, touchedFace);
           llSleep(0.1);
           // color detected face back to original color
           llSetColor(originalColor, touchedFace);
       }
   }

}

</lsl>

See Also

Deep Notes

History

Search JIRA for related Issues

Signature

function integer llDetectedTouchFace( integer index );