Original creations in Second Life by Oggy Fink.

Saturday, August 27, 2011

ShowHide script

Here is a little script I quickly put together. Its job is to make an entire object (a whole link-set) disappear or appear upon "hearing" a command on a private channel. It also takes "care" of hiding and showing the text above the object (but see details below).

This script is very simple but proves useful for hiding simple things like pose balls. Do not use it however for things more complicated, like a house or a tent, because the mechanism the script uses to make the object disappear will alter the alpha (transparency) setting of all faces of all prims in the object, and will make them fully opaque again when reappearing.

If you plan to have this functionnality on objects with partial transparency on some faces, a way more subtle means to do this is required.

The channel number, as well as the SHOW and HIDE commands are customizable via easy parameters at the start of the script. Due to some limitation, the floating text, if any, to be set above the root prim has to be entered in the script too [Technical note : no apparent way of getting the text in a prim]. Currently the script is limitted to setting only the root prim's text (could be done in a different way but, well...). You can also set the color of said text in the parameters.

A second script (ShowHide control) is designed to be placed in an object (like a cube or a poster) to "toggle" the show and hide commands for objects in range that have the first script. That way, you can make all your poseballs appear or disappear at the same time by touching the control. Its parameters (channel and commands) should be the same as those of the ShowHide script.

One last useful tip : by setting the channel parameter to a negative number, you prevent avatars from issuing a direct command over the chat, and only the control script will be useable.

First, the ShowHide script :

// ShowHide script by Oggy Fink

// text to set above the root prim
string text="here";    // modify me, use "" for no text
vector color=<1.0,1.0,1.0>;    // color of the text

// modifiable parameters

integer channel = 8;    // channel number
string showcmd="SHOW";    // show command - use uppercase only
string hidecmd="HIDE";    // hide command - use uppercase only

// do not touch below

show() {

hide() {

default {
	state_entry() {

	listen(integer channel, string name, key id, string message) {
		string m=llToUpper(llStringTrim(message,STRING_TRIM));
		if (m==showcmd) {
		} else if (m==hidecmd) {

Then the ShowHide control script :

// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)
integer channel=8;    // channel number

string showtext="Show !";
string hidetext="Hide !";
vector color=<1.0,0.5,0.0>;    // color for the floating text : . Use <1.0,1.0,1.0> for white

string showcmd="SHOW";
string hidecmd="HIDE";

// do not modify below
integer visible=TRUE;

default {
	state_entry() {

	touch_start(integer total_number) {
		if (visible) {
		} else {

All this is downloadable for free at my marketplace store.