$nav ===== Function: llAttachToAvatarTemp ===== llAttachToAvatarTemp(integer attachment_point) Adds an inworld object to the given attachment point of the avatar who has [[constants/PERMISSION_ATTACH]] permissions. The object doesn't go to the inventory of the destination avatar, and it disappears on detach or logout/crash. Drop is also disabled. In other words, the attachment is temporary. ===== Parameters ===== === attachment_point === The attachment point to attach to. Zero (0) means the last attachment point the object was attached to (if the object wasn't previously attached, it defaults to Right Hand). The following constants can also be used: {{page>constants/attach/tpl}} ===== Notes ===== * The attachments are added, not replaced. * Note that temporary attachments can also be edited, therefore you should be careful with content permissions, as the items can be dragged out of the attachment, or the scripts opened if they are copyable/modifiable, etc. just like with any other kind of attachment. * An attached object can't be attached to a different attachment point; the function will silently fail. * Permissions are a requisite; if the script doesn't request them, an error will be said (i.e. 20m range) in [[constants/DEBUG_CHANNEL]]: "Cannot find the agent to attach to." * If permissions were requested but not granted, it will send an error to the owner only in **DEBUG_CHANNEL**: "Script trying to attach to owner but PERMISSION_ATTACH permission not set!" (confusingly, this error is also shown if the permissions were requested to someone other than the owner). Scripts can't hear this error. * The **PERMISSION_ATTACH** permission is revoked only when the object changes owner, when the granter responds to a new permission request from the same script that doesn't include it or responds by denying it, or when the script is reset. There's nothing the granter can do on his/her own to revoke them, if the script doesn't do another request. * Note that since the permission is revoked when the object changes owner, and attaching it forces an owner change, when it's attached, permission needs to be requested again for detaching it. [[llGetAttached]] can be used to distinguish whether the permission request is for attaching or for detaching. See [[#Complete examples]] below for an example. ===== Short examples ===== llAttachToAvatarTemp(0); // attaches the object temporarily to the default attachment point // (assuming permissions are granted, the object isn't already attached and the granter is in the sim) llAttachToAvatarTemp(ATTACH_REAR); // attaches to the right ear (nothing to do with the bum) llAttachToAvatarTemp(14); // same as above ===== Complete examples ===== This script attaches a temporary attachment on click, and detaches it when the wearer clicks it again. It demonstrates the basic operation of a temp attachment with detach option. default { touch_start(integer n) { if (! llGetAttached()) // request attach llRequestPermissions(llDetectedKey(0), PERMISSION_ATTACH); else if (llDetectedKey(0) == llGetOwner()) // only the wearer can detach // request permissions again for detach (permissions are lost when the object attaches) llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); } run_time_permissions(integer perms) { if (perms & PERMISSION_ATTACH) { // Detach if already attached; otherwise attach if (llGetAttached()) llDetachFromAvatar(); else llAttachToAvatarTemp(0); } else llOwnerSay("Attach permission request denied, not attaching"); } } ===== See also ===== * [[llAttachToAvatar]] is similar, but the attachment goes to the receiver's inventory. It only works for owner, though. * [[events/attach]] event is generated when an object is attached or detached. * [[llRequestPermissions]] is used to requests permissions from an avatar, in particular **PERMISSION_ATTACH** required by this function. * [[events/run_time_permissions]] event is generated when the result of the permissions request is ready. * [[llDetachFromAvatar]] to detach the object if attached (also requires **PERMISSION_ATTACH**). * [[llGetAttached]] to get the attachment point.