OsDropAttachment
From OpenSimulator
(Difference between revisions)
m (Added note stating which version of OpenSim introduced this function) |
m (Change See Also) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{osslfunc | {{osslfunc | ||
− | |function_syntax= | + | |function_syntax= osDropAttachment() |
|threat_level=Moderate | |threat_level=Moderate | ||
− | |permissions=${ | + | |permissions=${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER |
|delay=0 | |delay=0 | ||
|description=Requires script to be granted [[PERMISSION_ATTACH]], drops an attachment like a user-triggered attachment drop. | |description=Requires script to be granted [[PERMISSION_ATTACH]], drops an attachment like a user-triggered attachment drop. | ||
− | |additional_info=This function was added in 0.7.5-post-fixes | + | |ossl_example=<source lang="lsl"> |
+ | // | ||
+ | // osDropAttachment Script Example (XEngine) | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand."); | ||
+ | llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachment drop this object on the ground in front of your avatar."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | if (!llGetAttached()) | ||
+ | { | ||
+ | llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); | ||
+ | } | ||
+ | |||
+ | else if (llGetAttached()) | ||
+ | { | ||
+ | osDropAttachment(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 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(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | ''' For YEngine: ''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osDropAttachment Script Example (YEngine) | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand."); | ||
+ | llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachment drop this object on the ground in front of your avatar."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | if (!llGetAttached()) | ||
+ | { | ||
+ | llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); | ||
+ | } | ||
+ | |||
+ | else if (llGetAttached()) | ||
+ | { | ||
+ | osDropAttachment(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 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(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |additional_info=This function was added in 0.7.5-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 18:42, 5 December 2020
osDropAttachment()
| |
Requires script to be granted PERMISSION_ATTACH, drops an attachment like a user-triggered attachment drop. | |
Threat Level | Moderate |
Permissions | ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER |
Extra Delay | 0 seconds |
Example(s) | |
// // osDropAttachment Script Example (XEngine) // Author: djphil // default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand."); llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachment drop this object on the ground in front of your avatar."); } touch_start(integer number) { if (!llGetAttached()) { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); } else if (llGetAttached()) { osDropAttachment(); } } 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: // // osDropAttachment Script Example (YEngine) // Author: djphil // default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see llAttachToAvatar attach this object to your avatar's left hand."); llSay(PUBLIC_CHANNEL, "Touch it again to see osDropAttachment drop this object on the ground in front of your avatar."); } touch_start(integer number) { if (!llGetAttached()) { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); } else if (llGetAttached()) { osDropAttachment(); } } 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. |