Chat activated and repeat
|
|
Lewis Nerd
Nerd by name and nature!
Join date: 9 Oct 2005
Posts: 3,431
|
07-21-2006 00:17
What I am trying to do is a chat activated lightshow which has 3 settings - off, all white, and sequenced flashing colours. The 'listen' part works fine, because it says the option that changes the 'type' integer... but that changed integer doesn't seem to follow through to the rest of the script to respond appropriately. Every option just seems to default to "0" - off. I want the option chosen to repeat forever, until I give it another command on /39. What am I doing wrong? I know it's just a silly thing because it almost works but I just can't get it. I've edited out the irrelevant bits to give you just the change bits. Lewis integer type = 0;
default { state_entry() { llListen(39,"","",""); } listen(integer channel, string name, key id, string m) {
if ( m=="off") {type==0; llSay (0,"off");} else if ( m=="white") {type==1; llSay (0,"white");} else if ( m=="colour") {type==2; llSay (0,"colour");}
// off if ( type==0)
{
// turn all the lights off
}
//white else if ( type==1)
{
// make all the lights go white
}
//white else if ( type==2)
{
// flash the lights } state default; } }
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
07-21-2006 00:40
You're using the comparison (==) instead of the assignment (=) there. You want something like if (m == "off") { type = 0; llSay(0, "off"); }and so on.
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-21-2006 00:46
From: Lewis Nerd if ( m=="colour") {type==2; llSay (0,"colour");} Completely unrelated (because Ordinal already covered the important part) but would suggest to add extra line in there that checks for "color" as well... or you're likely to get plenty customers bitching about broken item you're selling ^^;;
|
|
Lewis Nerd
Nerd by name and nature!
Join date: 9 Oct 2005
Posts: 3,431
|
07-21-2006 01:04
Hmmm odd. Changed the == to =. Now the lights are permanently white (1) - but whenever you type absolutely anything on /39 it says "off" (0) but stays white (1). I don't plan on selling this item, but will add the "color" command for the non-English speaking players Lewis
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
07-21-2006 01:42
From: Lewis Nerd Hmmm odd.
Changed the == to =.
Now the lights are permanently white (1) - but whenever you type absolutely anything on /39 it says "off" (0) but stays white (1). It's possible you changed too many =='s into ='s in there? It's only assignments that need to be changed, so need to be a bit careful with that ^^; if( m == "off") // comparison { type = 0; // assignment llSay (0,"off"); } else if ( m == "white") // comparison {type = 1; // assignment llSay (0,"white"); } else if ( m == "colour" ) // comparison {type = 2; // assignment llSay (0,"colour");}
// you have just comparisons in code past that point so =='s are correct there
|
|
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
|
07-21-2006 02:01
if ("off" == m) //... if ("off" = m2)
If you put the constant first, the LSL compiler will catch your error of putting "=" instead of "==" (as in the second if).
|
|
Lewis Nerd
Nerd by name and nature!
Join date: 9 Oct 2005
Posts: 3,431
|
07-21-2006 03:39
Ok.... I got it working sort of. if ( type==0)
{ // turn all the lights off } seemed to fix it.... however now the colour sequence goes through just once, and it seems to need to be told to go through the sequence again. Time to figure out how to repeat something until it gets told otherwise. else if ( type==2)
{
// flash pretty lights and stuff state default; } I would have thought that would have gone back to the start, where it already realised that "type" was 2, and started again - evidently not. Thanks for the help so far. Lewis
|
|
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
|
07-21-2006 04:08
a state change TO the current state does nothing. It isn't a change of state, so it doesn't trigger any events or anything else.
|