Created
March 3, 2014 17:45
-
-
Save antonyfairport/9330397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// Simple owner-only RLV attachment locker. | |
// By Antony Fairport | |
// | |
// Simple script to lock an attachment on an avatar, using RLV. This | |
// is owner-only touch to lock/unlock. The idea being that it's | |
// helpful to stop something being knocked off during outfit changes. | |
////////////////////////////////////////////////////////////////////// | |
// Allow the object we're in to be removed. | |
RLVUnlock() | |
{ | |
llOwnerSay( "@detach=y" ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Don't allow the object we're in to be removed. | |
RLVLock() | |
{ | |
llOwnerSay( "@detach=n" ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Default state. | |
default | |
{ | |
/////////////////////////////////////////////////////////////////// | |
// State entry. We'll just run to the unlocked state. | |
state_entry() | |
{ | |
state Unlocked; | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Unlocked state. | |
state Unlocked | |
{ | |
////////////////////////////////////////////////////////////////// | |
// State entry. | |
state_entry() | |
{ | |
// Ensure we can be removed. | |
RLVUnlock(); | |
// Give a clue as to our state. | |
llOwnerSay( "Unlocked" ); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle a touch. | |
touch_end( integer _ ) | |
{ | |
// Is it the owner touching us? | |
if ( llDetectedKey( 0 ) == llGetOwner() ) | |
{ | |
// ...sure is. Let's lock this thing! | |
state Locked; | |
} | |
} | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Locked state. | |
state Locked | |
{ | |
////////////////////////////////////////////////////////////////// | |
// State entry. | |
state_entry() | |
{ | |
// Ensure we can't be removed. | |
RLVLock(); | |
// Give a clue as to our state. | |
llOwnerSay( "Locked" ); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Ensure we're locked when rezzed. | |
on_rez( integer _ ) | |
{ | |
// If we're attached... | |
if ( llGetAttached() ) | |
{ | |
// ...being rezzed while attached normally means that | |
// we're logging in. So reaffirm the RLV lock. | |
RLVLock(); | |
} | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle a touch. | |
touch_end( integer _ ) | |
{ | |
// Is it the owner touching us? | |
if ( llDetectedKey( 0 ) == llGetOwner() ) | |
{ | |
// ...sure is. Let's unlock this thing! | |
state Unlocked; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment