OsForceAttachToAvatarFromInventory

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "{{osslfunc |function_syntax=void osForceAttachToAvatarFromInventory(string rawAvatarId, string itemName, integer attachmentPoint) |csharp_syntax= |description=Attach an inventory...")
 
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{osslfunc
 
{{osslfunc
|function_syntax=void osForceAttachToAvatarFromInventory(string rawAvatarId, string itemName, integer attachmentPoint)
+
|function_syntax= osForceAttachToAvatarFromInventory(string itemName, integer attachmentPoint)
 
|csharp_syntax=
 
|csharp_syntax=
|description=Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH.  Nothing happens if the avatar is not in the region.
+
|description=Attach an inventory item in the object containing this script to the script owner without asking for PERMISSION_ATTACH.   
 +
 
 +
Nothing happens if the avatar is not in the region.
  
* rawAvatarId - The UUID of the avatar to which to attach.  Nothing happens if this is not a UUID.
 
 
* itemName - The name of the item.  If this is not found then a warning is said to the owner.
 
* itemName - The name of the item.  If this is not found then a warning is said to the owner.
 
* attachmentPoint - The attachment point.  For example, ATTACH_CHEST.
 
* attachmentPoint - The attachment point.  For example, ATTACH_CHEST.
 +
|threat_level=High
 +
|permissions=${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
 +
|delay=0
 +
|ossl_example=<source lang="lsl">
 +
//
 +
// osForceAttachToAvatarFromInventory Script Exemple (XEngine)
 +
// Author: djphil
 +
//
 +
 +
string ObjectName;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        ObjectName = llGetInventoryName(INVENTORY_OBJECT, 0);
 +
 +
        if (ObjectName == "")
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Inventory object missing ...");
 +
        }
 +
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatarFromInventory attach the object " + ObjectName + " to your avatar's left hand.");
 +
        }
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        osForceAttachToAvatarFromInventory(ObjectName, ATTACH_LHAND);
 +
    }
 +
 +
    // 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 " + ObjectName + " 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();
 +
        }
 +
    }
 +
}
 +
</source>
 +
''' For YEngine: '''
 +
<source lang="lsl">
 +
//
 +
// osForceAttachToAvatarFromInventory Script Exemple (YEngine)
 +
// Author: djphil
 +
//
 +
 +
string ObjectName;
 +
 +
default
 +
{
 +
    state_entry()
 +
    {
 +
        ObjectName = llGetInventoryName(INVENTORY_OBJECT, 0);
 +
 +
        if (ObjectName == "")
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Inventory object missing ...");
 +
        }
 +
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatarFromInventory attach the object " + ObjectName + " to your avatar's left hand.");
 +
        }
 +
    }
 +
 +
    touch_start(integer number)
 +
    {
 +
        osForceAttachToAvatarFromInventory(ObjectName, ATTACH_LHAND);
 +
    }
 +
 +
    // 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 " + ObjectName + " is attached to " + llKey2Name(id));
 +
        }
 +
 +
        else
 +
        {
 +
            llOwnerSay("The object is not attached!");
 +
        }
 +
    }
  
In current OpenSimulator 0.7.4 development code only.
+
    on_rez(integer param)
|threat_level=high
+
    {
|ossl_example=
+
        // Reset the script if it's not attached.
|additional_info=
+
        if (!llGetAttached())       
 +
        {
 +
            llResetScript();
 +
        }
 +
    }
 +
}
 +
</source>
 +
|additional_info=This function was added in 0.7.4-post-fixes.<br>
 +
See [http://wiki.secondlife.com/wiki/Template:LSL_Constants_Attachment Attachment Points] for the complete list of LSL Attachment Points Constants.
 
}}
 
}}
 +
== See Also ==
 +
* [[osForceAttachToAvatar]]
 +
* [[osForceAttachToAvatarFromInventory]]
 +
* [[osForceAttachToOtherAvatarFromInventory]]
 +
* [[osForceDetachFromAvatar]]
 +
* [[osForceDropAttachment]]
 +
* [[osForceDropAttachmentAt]]
 +
* [[osDropAttachment]]
 +
* [[osDropAttachmentAt]]

Latest revision as of 05:34, 11 January 2021

osForceAttachToAvatarFromInventory(string itemName, integer attachmentPoint)
Attach an inventory item in the object containing this script to the script owner without asking for PERMISSION_ATTACH.

Nothing happens if the avatar is not in the region.

  • itemName - The name of the item. If this is not found then a warning is said to the owner.
  • attachmentPoint - The attachment point. For example, ATTACH_CHEST.
Threat Level High
Permissions ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
//
// osForceAttachToAvatarFromInventory Script Exemple (XEngine)
// Author: djphil
//
 
string ObjectName;
 
default
{
    state_entry()
    {
        ObjectName = llGetInventoryName(INVENTORY_OBJECT, 0);
 
        if (ObjectName == "")
        {
            llSay(PUBLIC_CHANNEL, "Inventory object missing ...");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatarFromInventory attach the object " + ObjectName + " to your avatar's left hand.");
        }
    }
 
    touch_start(integer number)
    {
        osForceAttachToAvatarFromInventory(ObjectName, ATTACH_LHAND);
    }
 
    // 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 " + ObjectName + " 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:

//
// osForceAttachToAvatarFromInventory Script Exemple (YEngine)
// Author: djphil
//
 
string ObjectName;
 
default
{
    state_entry()
    {
        ObjectName = llGetInventoryName(INVENTORY_OBJECT, 0);
 
        if (ObjectName == "")
        {
            llSay(PUBLIC_CHANNEL, "Inventory object missing ...");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Touch to see osForceAttachToAvatarFromInventory attach the object " + ObjectName + " to your avatar's left hand.");
        }
    }
 
    touch_start(integer number)
    {
        osForceAttachToAvatarFromInventory(ObjectName, ATTACH_LHAND);
    }
 
    // 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 " + ObjectName + " 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.4-post-fixes.

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


[edit] See Also

Personal tools
General
About This Wiki