Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

basic hide/show script help needed

Sky Eclipse
Registered User
Join date: 30 Oct 2006
Posts: 123
09-01-2008 12:34
This script does the job i need it to do perfectly, however,the build i am currently using it in requires multiple prims within the same item to use the script at the same time, using opposite commands.

ie, i want some prims to disappear and some to appear using one command and the reverse with the opposite command, this works perfectly until i link the object.... how do i alter this script to make each prim listen for the command and not make the whole build appear and dissappear?

thankyou

heres the script

default
{
state_entry()
{
llListen(0,"","","";);
}

on_rez(integer param)
{
llResetScript();
}

listen(integer c, string n, key k, string m)
{
if(m=="Rest";) llSetLinkAlpha(LINK_SET,1.0,ALL_SIDES);
else if (m=="Wake";) llSetLinkAlpha(LINK_SET,0.0,ALL_SIDES);
}
}
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
09-01-2008 13:12
Put the script in each prim to (dis)appear. Not in the rootprim.
Then change the lines in the listen event to:

if (llToLower(m) == "rest";) llSetAlpha(1.0, ALL_SIDES);
else if (llToLower(m) == "wake";) llSetAlpha(0.0, ALL_SIDES);

Swap 'rest' and 'wake' to make it work the other way around.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-01-2008 14:42
A considerably less laggy way of doing it than having a separate listen in each prim would be to put something like this in one prim:
CODE
default
{
state_entry()
{
llListen(5, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
string str = message;
// if (llToLower(str) == "show") uncomment if you want to show/hide the listening prim
// {
// llSetAlpha(1.0, ALL_SIDES);
// }
// else if (llToLower(str) == "hide")
// {
// llSetAlpha(0.0, ALL_SIDES);
// }
llMessageLinked(LINK_SET, 0, str, id);
}
}
and this in each prim in the linkset you want to show or hide:
CODE
default
{


link_message(integer sender_num, integer num, string str, key id)
{
if (llToLower(str) == "show")
{
llSetAlpha(1.0, ALL_SIDES);
}
else if (llToLower(str) == "hide")
{
llSetAlpha(0.0, ALL_SIDES);
}
}
}


AFTERTHOUGHT

Perhaps a better way of doing it, since we're only deciding once what to do? Does this affect performance? Anyway:
CODE
default
{
state_entry()
{
llListen(5, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
string str = message;
float myAlpha;
if (llToLower(str) != "show" && llToLower(str) != "hide" )
return;
if (llToLower(str) == "show")
myAlpha = 1.0;
if (llToLower(str) == "hide")
myAlpha = 0.0;

llMessageLinked(LINK_SET, 0, (string)myAlpha, id);
//llSetAlpha(myAlpha, ALL_SIDES); uncomment if you want to change this prim

}
}

and
CODE
default
{


link_message(integer sender_num, integer num, string str, key id)
{
llSetAlpha((float)str, ALL_SIDES);
}
}

in the other linked prims you want to change.