Difference between revisions of "LlDetachFromAvatar"

From Second Life Wiki
Jump to navigation Jump to search
 
(27 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{LSL_Function
{{Issues/VWR-12525}}{{Issues/VWR-16294}}{{LSL_Function/permission|PERMISSION_ATTACH|grant=the owner}}{{LSL_Function
|func_id=114|func_sleep=0.0|func_energy=10.0
|func_id=114|func_sleep=0.0|func_energy=10.0
|sort=DetachFromAvatar|func=llDetachFromAvatar
|sort=DetachFromAvatar|func=llDetachFromAvatar
|func_footnote=The object remains in the users inventory.
|func_footnote=The detached object remains in the user's inventory (unless it was a temporary attachment, in which case it will be destroyed).
|func_footnote=The detached object is no longer present in the sim. There is no lsl equivilent of the "Drop" command that moves an attachment onto the ground. Use [[llRezObject]] if you need similar behavior
|func_desc=Detach object from avatar.
|func_desc=Detach object from avatar.
|return_text
|return_text
|spec
|spec
|caveats
|caveats=
* Only works in the root prim of the attachment; calling it from a script in a child prim will cause it to fail silently.
* If the attachment was attached using [[llAttachToAvatarTemp]], the [[attach]]() [[event]] will ''not'' be called because the object will be destroyed before the event gets processed.
|constants
|constants
|examples
|examples=
<source lang="lsl2">
default
{
    attach(key AvatarKey)
    {//give instructions for use and prevent item from being attached to avatar
        if(AvatarKey)
        {//event is called on both attach and detatch, but Key is only valid on attach
            llOwnerSay ("
            We hope you will enjoy your purchase,
            but if you really want to use this item properly, you should:
            1) drag it from your inventory to the ground
            2) Right click on it and select \"open\"
            3) copy its contents to inventory.");
 
            llRequestPermissions(AvatarKey, PERMISSION_ATTACH );
        }
    }
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_ATTACH)
        {
            llDetachFromAvatar( );
        }
    }
}
</source>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||{{LSLG|llAttachToAvatar}}|}}
{{LSL DefineRow||[[llAttachToAvatar]]|}}
{{LSL DefineRow||{{LSLG|llGetAttached}}|}}
{{LSL DefineRow||[[llGetAttached]]|}}
|also_events=
|also_events=
{{LSL DefineRow||{{LSLG|attach}}|}}
{{LSL DefineRow||[[attach]]|}}
|also_articles
|also_articles
|permission=PERMISSION_ATTACH
|notes=There is no way to delete an attachment with a script or to drop it to the ground.
|notes
|cat1=Attachment
|cat1=Attachment
|cat2
|cat2=Avatar
|cat3
|cat3=Stop
|cat4
|cat4=Cleanup
}}
}}

Latest revision as of 15:50, 16 March 2023

Summary

Function: llDetachFromAvatar( );
0.0 Forced Delay
10.0 Energy

Detach object from avatar.

To run this function the script must request the PERMISSION_ATTACH permission with llRequestPermissions and it must be granted by the owner. The detached object is no longer present in the sim. There is no lsl equivilent of the "Drop" command that moves an attachment onto the ground. Use llRezObject if you need similar behavior

Caveats

Permissions
  • 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 except from inside the script (for example, with a new llRequestPermissions call) or the script is reset or deleted.
  • Only works in the root prim of the attachment; calling it from a script in a child prim will cause it to fail silently.
  • If the attachment was attached using llAttachToAvatarTemp, the attach() event will not be called because the object will be destroyed before the event gets processed.

Examples

default
{
    attach(key AvatarKey)
    {//give instructions for use and prevent item from being attached to avatar
        if(AvatarKey)
        {//event is called on both attach and detatch, but Key is only valid on attach
            llOwnerSay ("
            We hope you will enjoy your purchase, 
            but if you really want to use this item properly, you should: 
            1) drag it from your inventory to the ground 
            2) Right click on it and select \"open\"
            3) copy its contents to inventory.");

            llRequestPermissions(AvatarKey, PERMISSION_ATTACH );
        }
    }
    run_time_permissions(integer perm)
    {
        if(perm & PERMISSION_ATTACH)
        {
            llDetachFromAvatar( );
        }
    }
}

Notes

There is no way to delete an attachment with a script or to drop it to the ground.

See Also

Events

•  run_time_permissions Permission receiving event
•  attach

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llAttachToAvatar
•  llGetAttached

Articles

•  Script permissions

Deep Notes

Signature

function void llDetachFromAvatar();