LlAttachToAvatar
Function: llAttachToAvatar( integer attachment );
Attaches the object to the avatar who has granted permission to the script. The object is taken into the users inventory and attached to the attach point attachment.
• integer attachment – ATTACH_* constant or valid value (see the tables below)
Requires the PERMISSION_ATTACH permission, granted by the owner, to run.
If attachment is zero, then the object attaches to the attach point it was most recently attached to.
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Caveats
• Do not depend upon the auto-grant status of permissions. Always use the run_time_permissions event.
• If the script lacks the permission PERMISSION_ATTACH, the script will shout an error on DEBUG_CHANNEL and the operation fails (but the script continues to run).
• If PERMISSION_ATTACH is granted by anyone other than the owner, then when the function is called an error will be shouted on DEBUG_CHANNEL.
• Once the PERMISSION_ATTACH permission is granted there is no way to revoke it. The script will only lose the permission if it is reset or the object derezzed (deleted, detached, or taken).
• The call will fail if the avatar is not the owner of the object being attached, even if PERMISSION_ATTACH has been properly granted.
• Two objects cannot be attached to the same attachment point at the same time.
• 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 attachment is zero but the object was never previously attached, it defaults to the right hand (ATTACH_RHAND).
Examples
| <source lang="lsl">
//-- 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 (PERMISSION_ATTACH & vBitPermissions)
{
llAttachToAvatar( 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");
}
}
}
</source> |
See Also
Events
• run_time_permissions – Permission receiving event
Functions
• llGetPermissions – Get the permissions granted
• llGetPermissionsKey – Get the agent who granted permissions
• llRequestPermissions – Request permissions
• llDetachFromAvatar – Detaches the object from the avatar
• llGetAttached – Gets the attach point number
Articles
• Script permissions