Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Again, color change

Sin Poitier
RL is calling
Join date: 5 Mar 2007
Posts: 52
05-29-2007 23:50
I know this is a classic question, but i have some trouble with this script:

CODE

default
{

on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
llSetColor(<1,0,0>, -1);
llSetText("Busy", <1,0,0>, 1);
}

touch_start(integer num)
{
state on;
}
}

state on
{
state_entry()
{
llSetColor(<1,0,0>, -1);
llSetText("Empty", <1,1,1>, 1);
}

touch_start(integer num)
{
state default;
}
}



The idea is a simple prim to change color and hovertext when touched, and back when touched again. Plain simple and stupid, lol, but as i'm no scripter, and work this out looking some other examples, something is wrong: the prim doesn't allow the touch. Like there is no script in it.

PS: i resolved the problem before sending this post...the script was not running!!...but i send it anyway...someone could find it helpful someday.
_____________________
Me? No, i'm just part of your imagination.

C.I.G. CEO
Jefe de "Chilenos en SL"
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
05-30-2007 00:30
Here's your solution without the use of different states.

CODE

integer Toggle = FALSE;
string BusyText = "Busy!";
string NormText = "Not Busy...";

default
{
on_rez(integer X) {llResetScript();}

state_entry()
{
llSetColor(<0,1,0>,ALL_SIDES);
llSetText(NormText,<0,1,0>,1);
}

touch_start(integer Count)
{
Toggle = !Toggle;
if (Toggle)
{
llSetColor(<1,0,0>,ALL_SIDES);
llSetText(BusyText,<1,0,0>,1);
} else {
llSetColor(<0,1,0>,ALL_SIDES);
llSetText(NormText,<0,1,0>,1);
}
}
}
Sin Poitier
RL is calling
Join date: 5 Mar 2007
Posts: 52
05-30-2007 20:36
Good...how both work, but how can i decide which "approach" is better?? Is there a "good" way of doing it and a "bad" one?
_____________________
Me? No, i'm just part of your imagination.

C.I.G. CEO
Jefe de "Chilenos en SL"
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
05-30-2007 20:40
For something this simple, there is really no difference between the two worth worrying about; it boils down to a matter of taste. However, in a much more complex script, where you would change states frequently, it is often advised to use the single-state method over a multi-state method, because changing states has a significant bit of overheard attached to it that a single-state method does not.