Difference between revisions of "LlDetectedTouchFace"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
(3 intermediate revisions by 2 users not shown)
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>
<source lang="lsl2">
// This is the essential script to drop in a prim when you need to ascertain the number of a face (or faces)
// 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.
// Touch the prim surfaces to learn their face numbers, which you can then use in other scripts for texturing, colouring etc.
Line 39: Line 39:
     }
     }
}
}
</lsl>
</source>
<lsl>
<source lang="lsl2">
default
default
{
{
Line 48: Line 48:
         integer face = llDetectedTouchFace(0);
         integer face = llDetectedTouchFace(0);


         if (face == -1)
         if (face == TOUCH_INVALID_FACE)
             llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
             llSay(PUBLIC_CHANNEL, "Sorry, your viewer doesn't support touched faces.");
         else
         else
Line 69: Line 69:
     }
     }
}
}
</lsl>
</source>
|helpers
|helpers
|related
|related
Line 87: Line 87:
|history=*Introduced in Viewer {{SVN|870|rev=92872|branch=Release|anchor=file14|date=Wednesday, 23 July 2008}}.
|history=*Introduced in Viewer {{SVN|870|rev=92872|branch=Release|anchor=file14|date=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)
*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 [[ Release_Notes/Second_Life_Beta_Server/1.24#Release_Notes_for_Second_Life_Beta_Server_1.24.3_.28August_29th.2C_2008.29 | 29-08-2008 ]]
*Date of Release Client  [[ Release_Notes/Second_Life_Release/1.21 | 16-10-2008 ]]
|cat1=Touch
|cat1=Touch
|cat2=Face
|cat2=Face

Latest revision as of 23:58, 21 January 2015

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

// 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)
//      {
            say("The touched face could not be determined");
//      }
        else
//      {
            say("You touched face number " + (string) face);
//      }
    }
}
default
{
    touch_start(integer num_detected)
    {
        integer link = llDetectedLinkNumber(0);
        integer face = llDetectedTouchFace(0);

        if (face == TOUCH_INVALID_FACE)
            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);
        }
    }
}

See Also

Deep Notes

History

Signature

function integer llDetectedTouchFace( integer index );