Difference between revisions of "User:Toy Wylie/RLV Documentation/detach"

From Second Life Wiki
Jump to navigation Jump to search
(first draft)
 
m (Fixed code formating)
 
Line 15: Line 15:
|seealso=attach detachme detachthis detachallthis
|seealso=attach detachme detachthis detachallthis
|seealsoalso=Shared Objects Tutorial
|seealsoalso=Shared Objects Tutorial
|example=<lsl>lock()
|example=<source lang="lsl2">
lock()
{
{
     llOwnerSay("@detach=n");
     llOwnerSay( "@detach=n" );
     llOwnerSay("This attachment is now locked on. It will unlock automatically in 30 seconds.");
     llOwnerSay( "This attachment is now locked on. It will unlock automatically in 30 seconds." );
     llSetTimerEvent(30.0);
 
     llSetTimerEvent( 30.0 );
}
}
   
   
default
default
{
{
     on_rez(integer num)
     on_rez( integer num )
     {
     {
         llResetScript();
         llResetScript();
     }
     }
 
 
     state_entry()
     state_entry()
     {
     {
         if(llGetAttached()==0)
         if( llGetAttached() == 0 )
         {
         {
             llOwnerSay("@acceptpermission=add");
             llOwnerSay( "@acceptpermission=add" );
             llOwnerSay("Please attach me to your avatar.");
             llOwnerSay( "Please attach me to your avatar." );
             llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);
             llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
 
             return;
             return;
         }
         }
         lock();
         lock();
     }
     }


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


     touch_start(integer num)
 
     touch_start( integer num )
     {
     {
         if(llDetectedKey(0)==llGetOwner())
         if( llDetectedKey( 0 ) == llGetOwner() )
         {
         {
             llOwnerSay("@detach=force");
             llOwnerSay( "@detach=force" );
             llOwnerSay("Now all of your unlocked attachments have been detached.");
             llOwnerSay( "Now all of your unlocked attachments have been detached." );
         }
         }
     }
     }


     timer()
     timer()
     {
     {
         llSetTimerEvent(0.0);
         llSetTimerEvent( 0.0 );
         llOwnerSay("@detach=y");
         llOwnerSay(" @detach=y" );
         llOwnerSay("This attachment is now unlocked.");
         llOwnerSay(" This attachment is now unlocked." );
     }
     }


     run_time_permissions(integer perms)
 
     run_time_permissions( integer perms )
     {
     {
         if(perms & PERMISSION_ATTACH)
         if( perms & PERMISSION_ATTACH )
         {
         {
             llAttachToAvatar(ATTACH_RHAND);
             llAttachToAvatar( ATTACH_RHAND );
         }
         }
     }
     }
}
}
</lsl>
</source>
|example_2=<lsl>string folder="Outfits/Casual/Streetwear";
|example_2=<source lang="lsl2">
string folder = "Outfits/Casual/Streetwear";
 
 
 
default
default
{
{
     on_rez(integer num)
     on_rez( integer num )
     {
     {
         llResetScript();
         llResetScript();
     }
     }
 
 
     state_entry()
     state_entry()
     {
     {
         llOwnerSay("Touch me to detach the contents of the folder #RLV/"+folder);
         llOwnerSay( "Touch me to detach the contents of the folder #RLV/" + folder );
     }
     }
 
     touch_start(integer num)
 
     touch_start( integer num )
     {
     {
         if(llDetectedKey(0)==llGetOwner())
         if( llDetectedKey( 0 ) == llGetOwner() )
         {
         {
             llOwnerSay("@detach:"+folder+"=force");
             llOwnerSay( "@detach:" + folder + "=force" );
             llOwnerSay("Folder contents have been detached.");
             llOwnerSay( "Folder contents have been detached." );
         }
         }
     }
     }
}
}
</lsl>
</source>
}}
}}

Latest revision as of 17:40, 3 August 2019


@detach

Type

# Restriction
  1. General
  2. General

Implemented

Implemented since RLV version
  1. 1.0a
  2. 1.20
  3. 1.11

Usage

# @detach[:<attachmentpoint>]=<y/n>
  1. @detach[:<attachmentpoint>]=force
  2. @detach:<folder/path>=force

Purpose

# Locks an attachment point. The user won't be able to attach or detach anything to or from this attachment point. Leaving out the attachment point will result in a block of the attachment point of the object issuing the command only.
  1. Force detaches the attachment at the specified attachment point. If no attachment point is given, it will detach all attachments currently worn (which are not locked).
  2. Force detaches and unwears all items of the specified folder. If the folder has the same name as an attachment point, only that attachment point will be detached, so make sure not to name your folders after attachment points.


See Also

Shared Objects Tutorial

Example 1

lock()
{
    llOwnerSay( "@detach=n" );
    llOwnerSay( "This attachment is now locked on. It will unlock automatically in 30 seconds." );

    llSetTimerEvent( 30.0 );
}

 
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( "@detach=force" );
            llOwnerSay( "Now all of your unlocked attachments have been detached." );
        }
    }


    timer()
    {
        llSetTimerEvent( 0.0 );
        llOwnerSay(" @detach=y" );
        llOwnerSay(" This attachment is now unlocked." );
    }


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

Example 2

string folder = "Outfits/Casual/Streetwear";



default
{
    on_rez( integer num )
    {
        llResetScript();
    }


    state_entry()
    {
        llOwnerSay( "Touch me to detach the contents of the folder #RLV/" + folder );
    }


    touch_start( integer num )
    {
        if( llDetectedKey( 0 ) == llGetOwner() )
        {
            llOwnerSay( "@detach:" + folder + "=force" );
            llOwnerSay( "Folder contents have been detached." );
        }
    }
}