OsDropAttachmentAt

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Add new exemples)
m (Change See Also)
 
(3 intermediate revisions by one user not shown)
Line 7: Line 7:
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 
//
 
//
// osForceDropAttachmentAt Script Example (XEngine)
+
// osDropAttachmentAt Script Example (XEngine)
 +
// Author: djphil
 
//
 
//
  
 
vector pos;
 
vector pos;
 
rotation rot;
 
rotation rot;
 
+
 
default
 
default
 
{
 
{
Line 20: Line 21:
 
         rot = llGetRot();
 
         rot = llGetRot();
  
         llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatar attach this object to your avatar's left hand.");
+
         llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand.");
         llSay(PUBLIC_CHANNEL, "Touch it again to see osForceDropAttachmentAt drop this object to its original position and rotation.");
+
         llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachmentAt drop this object to its original position and rotation.");
 
         llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
 
         llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
 
     }
 
     }
Line 29: Line 30:
 
         if (!llGetAttached())
 
         if (!llGetAttached())
 
         {
 
         {
             osForceAttachToAvatar(ATTACH_LHAND);
+
             llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
 
         }
 
         }
  
 
         else if (llGetAttached())
 
         else if (llGetAttached())
 
         {
 
         {
             osForceDropAttachmentAt(pos, rot);
+
             osDropAttachmentAt(pos, rot);
 
         }
 
         }
 
     }
 
     }
  
 +
    run_time_permissions(integer perm)
 +
    {
 +
        if (perm & PERMISSION_ATTACH)   
 +
        {
 +
            llAttachToAvatar(ATTACH_LHAND);
 +
        }
 +
 +
        else
 +
        {
 +
            llOwnerSay("Permission to attach denied");
 +
        }
 +
    }
 +
 
     // The attach event is called on both attach and detach.
 
     // The attach event is called on both attach and detach.
 
     attach(key id)
 
     attach(key id)
Line 66: Line 80:
 
<source lang="lsl">
 
<source lang="lsl">
 
//
 
//
// osForceDropAttachmentAt Script Example (XEngine)
+
// osDropAttachmentAt Script Example (YEngine)
 +
// Author: djphil
 
//
 
//
  
 
vector pos;
 
vector pos;
 
rotation rot;
 
rotation rot;
 
+
 
default
 
default
 
{
 
{
Line 79: Line 94:
 
         rot = llGetRot();
 
         rot = llGetRot();
  
         llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatar attach this object to your avatar's left hand.");
+
         llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand.");
         llSay(PUBLIC_CHANNEL, "Touch it again to see osForceDropAttachmentAt drop this object to its original position and rotation.");
+
         llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachmentAt drop this object to its original position and rotation.");
 
         llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
 
         llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
 
     }
 
     }
Line 88: Line 103:
 
         if (!llGetAttached())
 
         if (!llGetAttached())
 
         {
 
         {
             osForceAttachToAvatar(ATTACH_LHAND);
+
             llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
 
         }
 
         }
  
 
         else if (llGetAttached())
 
         else if (llGetAttached())
 
         {
 
         {
             osForceDropAttachmentAt(pos, rot);
+
             osDropAttachmentAt(pos, rot);
 
         }
 
         }
 
     }
 
     }
  
 +
    run_time_permissions(integer perm)
 +
    {
 +
        if (perm & PERMISSION_ATTACH)   
 +
        {
 +
            llAttachToAvatar(ATTACH_LHAND);
 +
        }
 +
 +
        else
 +
        {
 +
            llOwnerSay("Permission to attach denied");
 +
        }
 +
    }
 +
 
     // The attach event is called on both attach and detach.
 
     // The attach event is called on both attach and detach.
 
     attach(key id)
 
     attach(key id)
 
     {
 
     {
         // Test if is a valid key('id' is only valid on attach)
+
         // Test if is a valid key ('id' is only valid on attach)
 
         if (id)
 
         if (id)
 
         {
 
         {
Line 125: Line 153:
 
See [http://wiki.secondlife.com/wiki/Template:LSL_Constants_Attachment Attachment Points] for the complete list of LSL Attachment Points Constants.
 
See [http://wiki.secondlife.com/wiki/Template:LSL_Constants_Attachment Attachment Points] for the complete list of LSL Attachment Points Constants.
 
}}
 
}}
'''See Also: '''
+
== See Also ==
 
* [[osForceAttachToAvatar]]
 
* [[osForceAttachToAvatar]]
 
* [[osForceAttachToAvatarFromInventory]]
 
* [[osForceAttachToAvatarFromInventory]]

Latest revision as of 18:43, 5 December 2020

osDropAttachmentAt(vector pos, rotation rot)
Requires script to be granted PERMISSION_ATTACH, drops an attachment at position pos with rotation rot
Threat Level Moderate
Permissions ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
//
// osDropAttachmentAt Script Example (XEngine)
// Author: djphil
//
 
vector pos;
rotation rot;
 
default
{
    state_entry()
    {
        pos = llGetPos();
        rot = llGetRot();
 
        llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand.");
        llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachmentAt drop this object to its original position and rotation.");
        llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
    }
 
    touch_start(integer number)
    {
        if (!llGetAttached())
        {
            llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
        }
 
        else if (llGetAttached())
        {
            osDropAttachmentAt(pos, rot);
        }
    }
 
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_ATTACH)     
        {
            llAttachToAvatar(ATTACH_LHAND); 
        }
 
        else
        {
            llOwnerSay("Permission to attach denied");
        }
    }
 
    // The attach event is called on both attach and detach.
    attach(key id)
    {
        // Test if is a valid key and not NULL_KEY ('id' is only valid on attach)
        if (id && id != NULL_KEY)
        {
            llOwnerSay("The object is attached to " + llKey2Name(id));
        }
 
        else 
        {
            llOwnerSay("The object is not attached!");
        }
    }
 
    on_rez(integer param)
    {
        // Reset the script if it's not attached.
        if (!llGetAttached())        
        {
            llResetScript();
        }
    }
}

For YEngine:

//
// osDropAttachmentAt Script Example (YEngine)
// Author: djphil
//
 
vector pos;
rotation rot;
 
default
{
    state_entry()
    {
        pos = llGetPos();
        rot = llGetRot();
 
        llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand.");
        llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachmentAt drop this object to its original position and rotation.");
        llSay(PUBLIC_CHANNEL, "The posistion is " + (string)pos + " and the rotation is " + (string)rot);
    }
 
    touch_start(integer number)
    {
        if (!llGetAttached())
        {
            llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
        }
 
        else if (llGetAttached())
        {
            osDropAttachmentAt(pos, rot);
        }
    }
 
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_ATTACH)     
        {
            llAttachToAvatar(ATTACH_LHAND); 
        }
 
        else
        {
            llOwnerSay("Permission to attach denied");
        }
    }
 
    // The attach event is called on both attach and detach.
    attach(key id)
    {
        // Test if is a valid key ('id' is only valid on attach)
        if (id)
        {
            llOwnerSay("The object is attached to " + llKey2Name(id));
        }
 
        else 
        {
            llOwnerSay("The object is not attached!");
        }
    }
 
    on_rez(integer param)
    {
        // Reset the script if it's not attached.
        if (!llGetAttached())        
        {
            llResetScript();
        }
    }
}
Notes
This function was added in 0.7.5-post-fixes.

See Attachment Points for the complete list of LSL Attachment Points Constants.


[edit] See Also

Personal tools
General
About This Wiki