A script that allows any worn object or HUD to be locked in place using RLV / RLVa (a.k.a. “Remote Scripted Viewer Controls).
I wrote this script so that items that I want to wear all the time cannot get detached when I change Outfits. Currently I use it with my wings, and my favourite HUDs. But you could use it on any object that you want to always wear, such as a wedding ring, a special necklace, or anything really.
It is suitable for any self-owned object, provided you can create a new script inside it. It is not suitable for a collar for BDSM use as it has no access list (as in, it can only be self-owned).
The script requires a viewer with RLV / RLVa (a.k.a. “Remote Scripted Viewer Controls”), which must be enabled. If not present, or disabled, then it will not work correctly.
To use, create a new script inside the wearable object or HUD that you wish to make lockable, and then paste my script into it and save it.
By default the script listens on channel 44. To change this to a different channel, edit the value of LISTENER_CHANNEL in the script.
The following commands are supported:
|status||Shows the current status of the object (ie. if it is locked or unlocked, shown or hidden, and which channel it is listening on).|
|lock||Locks the object so that it cannot be detached.|
|unlock||Unlocks the object again.|
|hide||Causes the entire object (or linkset) to be hidden.|
|show||Causes the entire object (or linkset) to be shown.|
You can disable the show / hide functionality by setting the ALLOW_HIDE variable to FALSE.
NOTE: You cannot edit the script whilst the object is locked. Simply unlock if you need to edit the script, eg. to change settings.
The very first version of this script drew inspiration from a script by Antony Fairport that used LSL’s state machine for the lock & unlock. However, I found that when used in HUDs this approach got easily confused, and also it involved too much duplicate code, so I dropped that idea and instead used a single state, recording the locked state with a variable. This makes it a lot more robust when used in other objects which have existing scripts running.
I hereby release the script under the same license as the Second Life source code – ie. the LGPL
This is all my own work, although I drew inspiration from an old script by Antony Fairport.