Follows the same convention as llAttachToAvatar, with the exception that the object will not create new inventory for the user, and will disappear on detach or disconnect. Also, this function can be used on avatars other than the owner (if granted permission) in which case the ownership is changed to the new wearer.

Syntax

void llAttachToAvatarTemp( integer attach_point );

Parameters

integer attach_point (attach_point)
ATTACH_* constant or valid value (see the tables below)

To run this function the script must request the PERMISSION_ATTACH permission with llRequestPermissions.

It should be noted that when an object is attached temporarily, a user cannot 'take' or 'drop' the object that is attached to them.

The user does not have to be the owner of the object in advance; this function transfers ownership automatically (the usual permissions required to transfer objects apply).

If attach_point is zero, then the object attaches to the attach point it was most recently attached to.

Constants

Constants in italic require a viewer compatible with the Project Bento skeleton.

Body

Constant#NameComment
ATTACH_HEAD2Skullhead
ATTACH_NOSE17Nosenose
ATTACH_MOUTH11Mouthmouth
ATTACH_FACE_TONGUE52Tonguetongue
ATTACH_CHIN12Chinchin
ATTACH_FACE_JAW47Jawjaw
ATTACH_LEAR13Left Earleft ear
ATTACH_REAR14Right Earright ear
ATTACH_FACE_LEAR48Alt Left Earleft ear (extended)
ATTACH_FACE_REAR49Alt Right Earright ear (extended)
ATTACH_LEYE15Left Eyeleft eye
ATTACH_REYE16Right Eyeright eye
ATTACH_FACE_LEYE50Alt Left Eyeleft eye (extended)
ATTACH_FACE_REYE51Alt Right Eyeright eye (extended)
ATTACH_NECK39Neckneck
ATTACH_LSHOULDER3Left Shoulderleft shoulder
ATTACH_RSHOULDER4Right Shoulderright shoulder
ATTACH_LUARM20L Upper Armleft upper arm
ATTACH_RUARM18R Upper Armright upper arm
ATTACH_LLARM21L Lower Armleft lower arm
ATTACH_RLARM19R Lower Armright lower arm
ATTACH_LHAND5Left Handleft hand
ATTACH_RHAND6Right Handright hand
ATTACH_LHAND_RING141Left Ring Fingerleft ring finger
ATTACH_RHAND_RING142Right Ring Fingerright ring finger
ATTACH_LWING45Left Wingleft wing
ATTACH_RWING46Right Wingright wing
ATTACH_CHEST1Chestchest/sternum
ATTACH_LEFT_PEC29Left Pecleft pectoral
ATTACH_RIGHT_PEC30Right Pecright pectoral
ATTACH_BELLY28Stomachbelly/stomach/tummy
ATTACH_BACK9Spineback
ATTACH_TAIL_BASE43Tail Basetail base
ATTACH_TAIL_TIP44Tail Tiptail tip
ATTACH_AVATAR_CENTER40Avatar Centeravatar center/root
ATTACH_PELVIS10Pelvispelvis
ATTACH_GROIN53Groingroin
ATTACH_LHIP25Left Hipleft hip
ATTACH_RHIP22Right Hipright hip
ATTACH_LULEG26L Upper Legleft upper leg
ATTACH_RULEG23R Upper Legright upper leg
ATTACH_RLLEG24R Lower Legright lower leg
ATTACH_LLLEG27L Lower Legleft lower leg
ATTACH_LFOOT7Left Footleft foot
ATTACH_RFOOT8Right Footright foot
ATTACH_HIND_LFOOT54Left Hind Footleft hind foot
ATTACH_HIND_RFOOT55Right Hind Footright hind foot

HUD

ConstantComment
ATTACH_HUD_CENTER_231HUD Center 2
ATTACH_HUD_TOP_RIGHT32HUD Top Right
ATTACH_HUD_TOP_CENTER33HUD Top
ATTACH_HUD_TOP_LEFT34HUD Top Left
ATTACH_HUD_CENTER_135HUD Center
ATTACH_HUD_BOTTOM_LEFT36HUD Bottom Left
ATTACH_HUD_BOTTOM37HUD Bottom
ATTACH_HUD_BOTTOM_RIGHT38HUD Bottom Right

Special

ConstantComment
ATTACH_ANY_HUD-1A special constant representing all HUD attachment points when filtering.

Caveats

Permissions

Examples

//-- rez object on ground, drop in this script, it will request permissions to attach,
//-- and then attach to the left hand if permission is granted. if permission is denied,
//-- then the script complains.
default
{
    state_entry()
    {
        llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
    }

    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }

    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }

    attach(key AvatarKey)
    {
        if(AvatarKey)
        {//event is called on both attach and detach, but Key is only valid on attach
            integer test = llGetAttached();
            if (test) {
                llOwnerSay( "The object is attached" );
            } else {
                llOwnerSay( "The object is not attached");
            }
        }
    }
}
//-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp()
//-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach,
//-- But not appear in Inventory.
default
{
    touch_start(integer num_touches)
    {
        llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH );
    }

    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }

    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
}
// This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership
// changes when the object is attached, the initial PERMISSION_ATTACH is revoked, and new permissions need to be requested.

integer gAttach = TRUE;

default
{

    touch_start(integer num)
    {
        if (gAttach)  // Object has not been attached yet
        {
            llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);
            gAttach = FALSE;
        }
        else   // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object
        {
            if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)
            {
                llDetachFromAvatar();  // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again
            }
        }
    }

    attach(key id)
    {
        if (id)  // Object has been attached, so request permissions again
        {
            llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions (integer perm)
    {
        if (!gAttach)  //First time
        {
            if (perm & PERMISSION_ATTACH)
            {
                gAttach = TRUE;
                llAttachToAvatarTemp(ATTACH_HEAD);  // Initial PERMISSION_ATTACH is revoked at this point
            }
        }
        else  // Second time
        {
            if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
            {
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }
}

An alternative solution:

// Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked, and new permissions need to be requested.

default
{
    touch_start(integer num)
    {
        if (!llGetAttached()) llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH);
        else if ( llGetPermissions() & PERMISSION_ATTACH) llDetachFromAvatar();
    }
    attach(key id)
    {
        if (id) llRequestPermissions( id, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions (integer perm)
    {
        if (!llGetAttached() && (perm & PERMISSION_ATTACH)) llAttachToAvatarTemp( ATTACH_NOSE);
        if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0));
    }
}

See also

Events

Functions

Articles

Deep notes

Issues

History

Date of Release 24/07/2012

Footnotes

  1. Multiple attachments per attach point were added as result of SCR-277