User:Toy Wylie/RLV Documentation/detachme

From Second Life Wiki
Jump to navigation Jump to search


@detachme

Type

General

Implemented

Implemented since RLV version 1.16.2

Usage

@detachme=force

Purpose

Detaches the object issuing this command. This is a useful function to work around a race condition when clearing restrictions before detaching the object. If you use @clear and then detach the object by using llDetachFromAvatar(), the object might get detached before the RLV command has reached the user's viewer. This might result in RLV re-attaching the object, because it was still locked on. Using the command sequence @clear,detachme=force will make sure that @clear is executed first, and only then @detachall will be executed.


See Also

Example

<lsl>lock()

{

   llOwnerSay("@detach=n");
   llOwnerSay("This attachment is now locked on. Click on it to unlock and detach it.");

}

default {

   on_rez(integer num)
   {
       llResetScript();
   }

   state_entry()
   {
       if(llGetAttached()==0)
       {
           llOwnerSay("@acceptpermission=add");
           llOwnerSay("Please attach me to your avatar.");
           llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);
           return;
       }
       lock();
   }

   attach(key k)
   {
       if(k!=NULL_KEY)
       {
           lock();
       }
   }

   touch_start(integer num)
   {
       if(llDetectedKey(0)==llGetOwner())
       {
           llOwnerSay("Unlocking the attachment and detaching.");
           llOwnerSay("@clear,detachme=force");
       }
   }

   run_time_permissions(integer perms)
   {
       if(perms & PERMISSION_ATTACH)
       {
           llAttachToAvatar(ATTACH_RHAND);
       }
   }

}

</lsl>