LlAttachToAvatar
Looking for the current API? Open the llAttachToAvatar reference →
Wiki description
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.Function notes
If
attach_point is zero, then the object attaches to the attach point it was most recently attached to.Specification
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Caveats
- Attach points can be occupied by multiple attachments.Multiple attachments per attach point were added as result of SCR-277
- This was not always the case, previously if
attach_pointwas occupied, the existing object was detached and the new attachment took it's place.
- This was not always the case, previously if
- 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_pointis 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_pointis a different attach point. -- SCR-137
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 )
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 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");
}
}See also: functions
See also: events
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Template:LSL Function/permission
Original shared helper source (conditional wiki logic is not evaluated)
{{#if:
{{{{#if:{{#var:DEBUG_CHANNEL}}||:DEBUG_CHANNEL}}|}}
{{#vardefine:header_footnote|{{#var:header_footnote}}{{#if:{{{1|<noinclude>*</noinclude>}}}|To run this function the script must request the [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} permission with [[llRequestPermissions]]{{#ifeq:{{{grant|anyone}}}|anyone|| and it must be granted by {{{grant|anyone}}}}}.}}}}
{{#vardefine:caveats|{{#var:caveats}}{{#if:{{{1|<noinclude>*</noinclude>}}}|{{PBR}}
<div style="border: 1px dotted rgba(0,0,0,0.5);">{{Collapsible_Table/Simple|title=<h5 style="margin:0;">Permissions</h5>|table-style=width:100%;|autocollapse=*|content={{!}}<div>
* Do not depend upon the auto-grant status of permissions. '''Always''' use the [[run_time_permissions]] event.
* If the script lacks {{#if:{{{2|}}}|both the permissions [[{{{1}}}]] and [[{{{2}}}]]|the permission [[{{{1}}}]]}}, the script will shout an error on {{#var:DEBUG_CHANNEL}} and the operation fails (but the script continues to run).{{#ifeq:{{{grant|anyone<noinclude>*</noinclude>}}}|anyone||
* If [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} is granted by anyone other than {{{grant|anyone}}}, then when the function is called an error will be shouted on {{#var:DEBUG_CHANNEL}}.}}
{{{caveats|}}}{{LSL Function/permission/caveat switch|{{{1}}}}}{{#if:{{{2|}}}|{{LSL Function/permission/caveat switch|{{{2}}}}}}}</div>}}</div>}}}}
{{#vardefine:also_events|{{#var:also_events}}
{{LSL DefineRow||[[run_time_permissions]]|Permission receiving event}}}}
{{#vardefine:also_functions|{{#var:also_functions}}
{{LSL DefineRow||[[llGetPermissions]]|Get the permissions granted}}
{{LSL DefineRow||[[llGetPermissionsKey]]|Get the agent who granted permissions}}
{{LSL DefineRow||[[llRequestPermissions]]|Request permissions}}}}
{{#vardefine:also_articles|{{#var:also_articles}}
{{LSL DefineRow||[[:Category:LSL Permissions/Script|Script permissions]]|}}}}
<includeonly>{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||[[Category:LSL Requires Permissions]]}}
}}}}</includeonly>
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|header_footnote}}
|-
{{VarPair|caveats}}
|-
{{VarPairTable|also_events}}
|-
{{VarPairTable|also_functions}}
|-
{{VarPairTable|also_articles}}
|}
</noinclude>Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|VWR-12525|[[llAttachToAvatar]]() can cause parentless [[attachments]] that can subsequently crash the client when selected|type=bug|resolution=fixed}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SCR-137|Allow [[llAttachToAvatar]]() to switch attachment locations|type=nf}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-890|[[llAttachToAvatar]] can cause a stack/heap collision in certain circumstances|type=bug}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SCR-277|Add companion command to [[llAttachToAvatar]]() to allow attaching multiple items in same attachment point|type=nf|fc=*|resolution=fixed}}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.