Unofficial LSL Reference

[[functions:llattachtoavatar]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

functions:llattachtoavatar [2015-01-09 20:38 SLT]
sei created (WIP)
functions:llattachtoavatar [2015-08-06 10:53 SLT] (current)
sei Scripts can't hear the error
Line 11: Line 11:
  
 === attachment_point === === attachment_point ===
-The attachment point to attach to. Zero (0) means the default ​attachment point for the object (if the object wasn't previously attached, it defaults to Right Hand). The following constants can also be used:+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}} {{page>​constants/​attach/​tpl}}
Line 17: Line 17:
 ===== Notes ===== ===== Notes =====
  
-  * This function only works for owner. It will shout an error in DEBUG_CHANNEL otherwise.+  * This function only works for attaching to the owner of the object.
   * The attachments are added, not replaced.   * The attachments are added, not replaced.
   * An attached object can't be attached to a different attachment point; the function will silently fail.   * An attached object can't be attached to a different attachment point; the function will silently fail.
-  * FIXME work in progress+  * 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. 
 +  * If permissions were granted to someone other than owner, when calling this function an error will be said (i.e. 20m range) in **DEBUG_CHANNEL**:​ "​Script trying to attach to someone other than owner!"​ 
 +  * 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.
  
 ===== Short examples ===== ===== Short examples =====
  
 <code lsl2> <code lsl2>
-llAttachToAvatar(12); // will do xxx+llAttachToAvatar(0); // attaches the object to the default attachment point 
 +// (assuming permissions are granted for the owner, 
 +// the object isn't already attached and the owner is in sim) 
 + 
 +llAttachToAvatar(ATTACH_REAR); // attaches to the right ear (nothing to do with the bum) 
 + 
 +llAttachToAvatar(14);​ // same as above
 </​code>​ </​code>​
  
 ===== Complete examples ===== ===== Complete examples =====
 +
 +This script requests permissions on touch and attaches to the default attachment point if granted:
  
 <file lsl2 llAttachToAvatar-example.lsl>​ <file lsl2 llAttachToAvatar-example.lsl>​
 default default
 { {
-    ​state_entry()+    ​touch_start(integer n) 
 +    { 
 +        if (llDetectedKey(0) != llGetOwner()) 
 +        { 
 +            llRegionSayTo(llDetectedKey(0),​ 0, "Not possible to attach to you, sorry."​);​ 
 +            return; 
 +        } 
 +        // Request permission to attach from owner. We'll attach if granted. 
 +        llRequestPermissions(llGetOwner(),​ PERMISSION_ATTACH);​ 
 +    } 
 + 
 +    run_time_permissions(integer perms)
     {     {
-        llAttachToAvatar(12);+        ​if (perms & PERMISSION_ATTACH) 
 +            ​llAttachToAvatar(0); 
 +        else 
 +            llOwnerSay("​Attach permission request deniednot attaching"​);
     }     }
 } }