User:Toy Wylie/RLV Documentation/detach

From Second Life Wiki
Jump to navigation Jump to search


@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." );
        }
    }
}