LlAttachToAvatarTemp
De DigiWiki.
(Différences entre les versions)
(Page créée avec « <lsl> //-- rez object on ground, drop in this script, it will request permissions to attach, //-- and then attach to the left hand if permission is granted. if permission is … ») |
|||
Ligne 41 : | Ligne 41 : | ||
} | } | ||
} | } | ||
+ | } | ||
+ | } | ||
+ | </lsl> | ||
+ | <lsl> | ||
+ | //-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp() | ||
+ | //-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach, | ||
+ | //-- But not appear in Inventory. | ||
+ | default | ||
+ | { | ||
+ | touch_start(integer num_touches) | ||
+ | { | ||
+ | llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH ); | ||
+ | } | ||
+ | |||
+ | run_time_permissions( integer vBitPermissions ) | ||
+ | { | ||
+ | if( vBitPermissions & PERMISSION_ATTACH ) | ||
+ | { | ||
+ | llAttachToAvatarTemp( ATTACH_LHAND ); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | llOwnerSay( "Permission to attach denied" ); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | on_rez(integer rez) | ||
+ | { | ||
+ | if(!llGetAttached()) | ||
+ | { //reset the script if it's not attached. | ||
+ | llResetScript(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </lsl> | ||
+ | <lsl> | ||
+ | // This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership | ||
+ | // changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested. | ||
+ | |||
+ | integer gAttach = TRUE; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | |||
+ | touch_start(integer num) | ||
+ | { | ||
+ | if (gAttach) // Object has not been attached yet | ||
+ | { | ||
+ | llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH); | ||
+ | gAttach = FALSE; | ||
+ | } | ||
+ | else // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object | ||
+ | { | ||
+ | if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH) | ||
+ | { | ||
+ | llDetachFromAvatar(); // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | attach(key id) | ||
+ | { | ||
+ | if (id) // Object has been attached, so request permissions again | ||
+ | { | ||
+ | llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | run_time_permissions (integer perm) | ||
+ | { | ||
+ | if (!gAttach) //First time | ||
+ | { | ||
+ | if (perm & PERMISSION_ATTACH) | ||
+ | { | ||
+ | gAttach = TRUE; | ||
+ | llAttachToAvatarTemp(ATTACH_HEAD); // Initial PERMISSION_ATTACH is revoked at this point | ||
+ | } | ||
+ | } | ||
+ | else // Second time | ||
+ | { | ||
+ | if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION) | ||
+ | { | ||
+ | llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0)); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </lsl> | ||
+ | <lsl> | ||
+ | // Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested. | ||
+ | |||
+ | default | ||
+ | { | ||
+ | touch_start(integer num) | ||
+ | { | ||
+ | if (!llGetAttached()) llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH); | ||
+ | else if ( llGetPermissions() & PERMISSION_ATTACH) llDetachFromAvatar(); | ||
+ | } | ||
+ | attach(key id) | ||
+ | { | ||
+ | if (id) llRequestPermissions( id, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION); | ||
+ | } | ||
+ | run_time_permissions (integer perm) | ||
+ | { | ||
+ | if (!llGetAttached() && (perm & PERMISSION_ATTACH)) llAttachToAvatarTemp( ATTACH_NOSE); | ||
+ | if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0)); | ||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Version du 11 octobre 2014 à 08:47
//-- rez object on ground, drop in this script, it will request permissions to attach, //-- and then attach to the left hand if permission is granted. if permission is denied, //-- then the script complains. default { state_entry() { llRequestPermissions( llGetOwner(), PERMISSION_ATTACH ); } run_time_permissions( integer vBitPermissions ) { if( vBitPermissions & PERMISSION_ATTACH ) { llAttachToAvatarTemp">llAttachToAvatarTemp( ATTACH_LHAND ); } else { llOwnerSay( "Permission to attach denied" ); } } on_rez(integer rez) { if(!llGetAttached()) { //reset the script if it's not attached. llResetScript(); } } attach(key AvatarKey) { if(AvatarKey) {//event is called on both attach and detach, but Key is only valid on attach integer test = llGetAttached(); if (test) { llOwnerSay( "The object is attached" ); } else { llOwnerSay( "The object is not attached"); } } } }
//-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp() //-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach, //-- But not appear in Inventory. default { touch_start(integer num_touches) { llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH ); } run_time_permissions( integer vBitPermissions ) { if( vBitPermissions & PERMISSION_ATTACH ) { llAttachToAvatarTemp">llAttachToAvatarTemp( ATTACH_LHAND ); } else { llOwnerSay( "Permission to attach denied" ); } } on_rez(integer rez) { if(!llGetAttached()) { //reset the script if it's not attached. llResetScript(); } } }
// This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership // changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested. integer gAttach = TRUE; default { touch_start(integer num) { if (gAttach) // Object has not been attached yet { llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH); gAttach = FALSE; } else // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object { if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH) { llDetachFromAvatar(); // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again } } } attach(key id) { if (id) // Object has been attached, so request permissions again { llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION); } } run_time_permissions (integer perm) { if (!gAttach) //First time { if (perm & PERMISSION_ATTACH) { gAttach = TRUE; llAttachToAvatarTemp">llAttachToAvatarTemp(ATTACH_HEAD); // Initial PERMISSION_ATTACH is revoked at this point } } else // Second time { if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION) { llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0)); } } } }
// Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested. default { touch_start(integer num) { if (!llGetAttached()) llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH); else if ( llGetPermissions() & PERMISSION_ATTACH) llDetachFromAvatar(); } attach(key id) { if (id) llRequestPermissions( id, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION); } run_time_permissions (integer perm) { if (!llGetAttached() && (perm & PERMISSION_ATTACH)) llAttachToAvatarTemp">llAttachToAvatarTemp( ATTACH_NOSE); if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0)); } }