Unofficial LSL Reference

[[functions:llattachtoavatar]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Function: llAttachToAvatar

llAttachToAvatar(integer attachment_point)

Adds an inworld object to the given attachment point of the avatar who has PERMISSION_ATTACH permissions (currently only allowed for owner).

Parameters

attachment_point

The attachment point to attach to. Zero (0) means the last attachment point the object was attached to (if the object wasn't previously attached, it defaults to Right Hand). The following constants can also be used:

Constant name Value Attachment point
ATTACH_CHEST 1 Chest
ATTACH_HEAD 2 Skull
ATTACH_LSHOULDER 3 Left Shoulder
ATTACH_RSHOULDER 4 Right Shoulder
ATTACH_LHAND 5 Left Hand
ATTACH_RHAND 6 Right Hand
ATTACH_LFOOT 7 Left Foot
ATTACH_RFOOT 8 Right Foot
ATTACH_BACK 9 Spine
ATTACH_PELVIS 10 Pelvis
ATTACH_MOUTH 11 Mouth
ATTACH_CHIN 12 Chin
ATTACH_LEAR 13 Left Ear
ATTACH_REAR 14 Right Ear
ATTACH_LEYE 15 Left Eye
ATTACH_REYE 16 Right Eye
ATTACH_NOSE 17 Nose
ATTACH_RUARM 18 Right Upper Arm
ATTACH_RLARM 19 Right Lower Arm
ATTACH_LUARM 20 Left Upper Arm
ATTACH_LLARM 21 Left Lower Arm
Constant name Value Attachment point
ATTACH_RHIP 22 Right Hip
ATTACH_RULEG 23 Right Upper Leg
ATTACH_RLLEG 24 Right Lower Leg
ATTACH_LHIP 25 Left Hip
ATTACH_LULEG 26 Left Upper Leg
ATTACH_LLLEG 27 Left Lower Leg
ATTACH_BELLY 28 Stomach
ATTACH_LEFT_PEC 29 Left Pectoral
ATTACH_RIGHT_PEC 30 Right Pectoral
ATTACH_HUD_TOP_CENTER 33 HUD Top
ATTACH_HUD_TOP_LEFT 34 HUD Top Left
ATTACH_HUD_TOP_RIGHT 32 HUD Top Right
ATTACH_HUD_CENTER_1 35 HUD Center
ATTACH_HUD_CENTER_2 31 HUD Center2
ATTACH_HUD_BOTTOM 37 HUD Bottom
ATTACH_HUD_BOTTOM_LEFT 36 HUD Bottom left
ATTACH_HUD_BOTTOM_RIGHT 38 HUD Bottom Right
ATTACH_NECK 39 Neck
ATTACH_AVATAR_CENTER 40 Root / Avatar Center


Notes

  • This function only works for attaching to the owner of the object.
  • The attachments are added, not replaced.
  • An attached object can't be attached to a different attachment point; the function will silently fail.
  • Permissions are a requisite; if the script doesn't request them, an error will be said (i.e. 20m range) in DEBUG_CHANNEL: "Cannot find the agent to attach to."
  • If permissions were requested but not granted, it will send an error to the owner only in DEBUG_CHANNEL: "Script trying to attach to owner but PERMISSION_ATTACH permission not set!" (confusingly, this error is also shown if the permissions were requested to someone other than the owner). Scripts can't hear this error.
  • If permissions were granted to someone other than owner, when calling this function an error will be said (i.e. 20m range) in DEBUG_CHANNEL: "Script trying to attach to someone other than owner!"
  • The PERMISSION_ATTACH permission is revoked only when the object changes owner, when the granter responds to a new permission request from the same script that doesn't include it or responds by denying it, or when the script is reset. There's nothing the granter can do on his/her own to revoke them, if the script doesn't do another request.

Short examples

llAttachToAvatar(0); // attaches the object to the default attachment point
// (assuming permissions are granted for the owner,
// the object isn't already attached and the owner is in sim)
 
llAttachToAvatar(ATTACH_REAR); // attaches to the right ear (nothing to do with the bum)
 
llAttachToAvatar(14); // same as above

Complete examples

This script requests permissions on touch and attaches to the default attachment point if granted:

llAttachToAvatar-example.lsl
default
{
    touch_start(integer n)
    {
        if (llDetectedKey(0) != llGetOwner())
        {
            llRegionSayTo(llDetectedKey(0), 0, "Not possible to attach to you, sorry.");
            return;
        }
        // Request permission to attach from owner. We'll attach if granted.
        llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
    }
 
    run_time_permissions(integer perms)
    {
        if (perms & PERMISSION_ATTACH)
            llAttachToAvatar(0);
        else
            llOwnerSay("Attach permission request denied, not attaching");
    }
}

See also

  • llAttachToAvatarTemp is similar, but the attached object disappears when detached or on logout and doesn't go to the receiver's inventory; in other words, the attach is temporary. It also allows attaching to avatars other than the owner.
  • attach event is generated when an object is attached or detached.
  • llRequestPermissions is used to requests permissions from an avatar, in particular PERMISSION_ATTACH required by this function.
  • run_time_permissions event is generated when the result of the permissions request is ready.
  • llDetachFromAvatar to detach the object if attached (also requires PERMISSION_ATTACH).
  • llGetAttached to get the attachment point.