Skip to content
lsl.devlsl.devLSL Dev

llDetectedTouchFace

function
Function syntax
integer llDetectedTouchFace(
  1. integer index// Index of the detection information.
);
Returns
integer
Energy
10

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.

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

How to use
integer result = llDetectedTouchFace(0);
  • 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.
Example 1
10 collapsed lines
// 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.
say(string message)
{
llSay(PUBLIC_CHANNEL, message);
}
default
{
touch_start(integer num_detected)
{
integer face = llDetectedTouchFace(0);
if (face == TOUCH_INVALID_FACE)
9 collapsed lines
// {
say("The touched face could not be determined");
// }
else
// {
say("You touched face number " + (string) face);
// }
}
}
Example 2
default
{
touch_start(integer num_detected)
{
integer link = llDetectedLinkNumber(0);
integer face = llDetectedTouchFace(0);
if (face == TOUCH_INVALID_FACE)
20 collapsed lines
llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
else
{
// store the original color
list colorParams = llGetLinkPrimitiveParams(link, [PRIM_COLOR, face]);
vector originalColor = llList2Vector(colorParams, 0);
// color detected face white
llSetLinkColor(link, <1.0, 1.0, 1.0>, face);
llSleep(0.2);
// color detected face black
llSetLinkColor(link, ZERO_VECTOR, face);
llSleep(0.2);
// color detected face back to original color
llSetLinkColor(link, originalColor, face);
}
}
}
  • Introduced in Viewer SVN:870 r92872 Branch:Release Wednesday, 23 July 2008.
  • Server support available in Second Life Server 1.24.7.98039, client support in Release Candidate viewer 1.21.4 (98167)
  • Date of Release Server 29-08-2008
  • Date of Release Client 16-10-2008
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.