Difference between revisions of "LlDetectedTouchFace"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 15: Line 15:
|examples=
|examples=
<lsl>
<lsl>
default {
default
{
    touch_start(integer num_detected)
    {
        integer touchedFace = llDetectedTouchFace(0);


    touch_start(integer num_detected) {
         // PUBLIC_CHANNEL has the integer value 0
         integer i;
         if (touchedFace == -1)
         for (i = 0; i < num_detected; i++) {
            llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
             integer touchedFace = llDetectedTouchFace(i);    
        else
        {
             // store the original color
            vector originalColor = llGetColor(touchedFace);


             if (touchedFace == -1) {
             // color detected face white
                llWhisper(0, "Sorry, your viewer doesn't support touched faces.");
            llSetColor(<1.0, 1.0, 1.0>, touchedFace);
             }
             llSleep(0.1);
            else {
                // Store away the original color
                vector oldColor = llGetColor(touchedFace);


                // Flash white and black on the touched face
            // color detected face black
                llSetColor(<1., 1., 1.>, touchedFace);
            // ZERO_VECTOR has the vector value <0.0, 0.0, 0.0>
                llSleep(0.1);
            llSetColor(ZERO_VECTOR, touchedFace);
                llSetColor(<0., 0., 0.>, touchedFace);
            llSleep(0.1);
                llSleep(0.1);
               
                // Put the color back to how we found it.
                llSetColor(oldColor, touchedFace);
            } // if ...
        } // for ...
    } // touch_start


            // color detected face back to original color
            llSetColor(originalColor, touchedFace);
        }
    }
}
}
</lsl>
</lsl>

Revision as of 06:32, 23 September 2012

Summary

Function: integer llDetectedTouchFace( integer index );
0.0 Forced Delay
10.0 Energy

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.

Examples

<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

Signature

function integer llDetectedTouchFace( integer index );