Original creations in Second Life by Oggy Fink.


Monday, September 19, 2011

ShowHide-Multi script

Since the recent release of the ShowHide script, some people have asked me for a way to make some prims of an object vanish, but not others.

Guess what ? Here it comes !

It's called ShowHide-Multi. The "Multi" part means that you can use several copies of the script in several prims of your object to make them disappear at the same time. The script is either controlled by chat over a private channel, or by link messages.

Private chat will work from a distance and may be issued directly by the viewer but can cause some server lag if many scripts are listening. Link messages, on the other hand, will cause less lag but will work only among the prims of a same object. Moreover, link messages require a helper script.

All is customizable, and a control script is available to emit either private chat or link messages. Please be sure to read the options available at the beginning of both scripts.

Again, i warn you against using this script on partially transparent prims, because the alpha setting of all faces of the prim will be overwritten by the vanishing manoeuvers :) (usual disclaimers apply).

Here is the ShowHide-Multi script to be placed in every prim that is to disappear.
// ShowHide-Multi 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

integer listen_active=TRUE;	// should I listen to chat commands in addition to link messages?

// do not touch below

show() {
	llSetAlpha(1.0,ALL_SIDES);
	llSetText(text,color,1.0);
}

hide() {
	llSetAlpha(0.0,ALL_SIDES);
	llSetText("",color,1.0);
}

interpret(string message) {	// detects if it is a show or hide command and reacts
	string m=llToUpper(llStringTrim(message,STRING_TRIM));
	if (m==showcmd) {
		show();
	} else if (m==hidecmd) {
		hide();
	}
}

default {
	state_entry() {
		if (listen_active) llListen(channel,"",NULL_KEY,"");
		show();
	}

	link_message(integer sender_number, integer number, string message, key id) {
		if (number!=channel) { // the channel number acts as a key here
			return;
		}
		interpret(message);
	}
	
	listen(integer channel, string name, key id, string message) {
		interpret(message);
	}
}
Then the ShowHide-Multi control script :
// www.lsleditor.org  by Alphons van der Heijden (SL: Alphons Jano)
integer channel=8;    // channel number / link key

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";

// the following parameter sets if the command should be "said" (0), "whispered" (1), "shouted" (2), "regionsaid" (3) or sent as a link message (4)
integer emittype=0;	// edit accordingly


// do not modify below
integer visible=TRUE;

emit(string m) { // send a command
	if (emittype==0) {
		llSay(channel,m);
	} else if (emittype==1) {
		llWhisper(channel,m);
	} else if (emittype==2) {
		llShout(channel,m);
	} else if (emittype==3) {
		llRegionSay(channel,m);
	} else if (emittype==4) {
		llMessageLinked(LINK_SET,channel,m,NULL_KEY);
	}
}

default {
	state_entry() {
		llSetText(hidetext,color,1.0);
	}

	touch_start(integer total_number) {
		if (visible) {
			emit(hidecmd);
			visible=FALSE;
			llSetText(showtext,color,1.0);
		} else {
			emit(showcmd);
			visible=TRUE;
			llSetText(hidetext,color,1.0);
		}
	}
}
All this is downloadable for free at my marketplace store.

No comments:

Post a Comment