llAttachToAvatar
function
Function syntax
llAttachToAvatar(integer attach_point// ATTACH_* constant or integer value representing the target attachment point. Values: AttachPoint
);- Energy
- 10
- Permission
PERMISSION_ATTACH
Attaches the object to the avatar who has granted permission to the script. The object is taken into the users inventory and attached to attach_point.
If attach_point is zero, then the object attaches to the attach point it was most recently attached to.
llAttachToAvatar(0);Specification
Section titled “Specification”Body
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Caveats
Section titled “Caveats”- Attach points can be occupied by multiple attachments.1
- This was not always the case, previously if attach_point was occupied, the existing object was detached and the new attachment took it’s place.
- Objects attached to the head (and any attachment position within the head) will not be visible in First Person view (aka Mouselook) if “show attachments in mouselook” is disable.
- If attach_point is zero but the object was never previously attached, it defaults to the right hand (
ATTACH_RHAND). - If the object is already attached the function fails silently, regardless if the attach_point is a different attach point. — SCR-137
Examples
Section titled “Examples”Example 1
11 collapsed lines
//-- 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 ) llAttachToAvatar( ATTACH_LHAND ); else llOwnerSay( "Permission to attach denied" );17 collapsed lines
}
on_rez(integer rez) { if (!llGetAttached() ) //reset the script if it's not attached. llResetScript(); }
attach(key id) { // The attach event is called on both attach and detach, but 'id' is only valid on attach if (id) llOwnerSay( "The object is attached to " + llKey2Name(id) ); else llOwnerSay( "The object is not attached"); }}Known issues
Section titled “Known issues”From the issue templates included by the wiki article:
- VWR-12525 (bug): llAttachToAvatar() can cause parentless attachments that can subsequently crash the client when selected
- SCR-137 (nf): Allow llAttachToAvatar() to switch attachment locations
- SVC-890 (bug): llAttachToAvatar can cause a stack/heap collision in certain circumstances
- SCR-277 (nf): Add companion command to llAttachToAvatar() to allow attaching multiple items in same attachment point
See also
Section titled “See also”Functions
Section titled “Functions”llAttachToAvatarTemp— Attach an object to any avatar but only temporarilyllDetachFromAvatar— Detaches the object from the avatarllGetAttached— Gets the attach point number (that the object is attached to)
Events
Section titled “Events”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.