Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Simple script not working :/

jamieparsons Lemon
undergrad n00b
Join date: 5 Nov 2008
Posts: 36
11-20-2008 12:54
// Data

list colours =
[
"Red",
"Green",
"Blue"
];

// End of data

key who;



default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
llListen(321,"",NULL_KEY,"Red";);
llListen(321, "", NULL_KEY, "Green";);
llListen(321, "", NULL_KEY, "Blue";);
}
touch_start(integer total_number)
{
who = llDetectedKey(0); // Assigns the name of the person who is in the quiz to the word 'who'.
llDialog(who, "Wanna change my outfit?", colours, 321);
}

listen(integer channel, string name, key id, string message)
{
if(message == "Red";)
{
llSetColor(<1,0,0>, ALL_SIDES);
}
else if(message == "Blue";){
llSetColor(<0,0,1>, ALL_SIDES);
}
else if(message == "Green";)
{
llSetColor(<0,1,0>, ALL_SIDES);
}
}


}




Object isn't changing colour! Anybody see the flaw?
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-20-2008 13:06
/me doesn't spot an obvious problem just by looking at the code..

Can you do multiple listens on the same channel? I've never seen that done before but have also never heard of it causing problems. I'd try doing only one listen and leaving the last parameter as "".

You probably only want to do the color change if (id == who) but that wouldn't make the code you have break.

Since you're using a positive channel, you can also test this by chatting. Does chatting /123blue cause anything to happen?

Also, llOwnerSay is a good debug tool. Try putting "llOwnerSay ("heard " + message);" right at the top of the listen event.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-20-2008 13:25
Surprised it compiles, you need one more bracket to close out default.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Cappy Frantisek
Open Source is the Devil!
Join date: 27 Oct 2006
Posts: 400
11-20-2008 13:29
From: Meade Paravane
/Can you do multiple listens on the same channel?

I wouldn't. Use an open filter ie. llListen(321,"",NULL_KEY,"";)
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
Do it like this;
11-20-2008 13:43
CODE


list colours =
[
"Red",
"Green",
"Blue"
];

// End of data

key who;
integer handle;


default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
who = llDetectedKey(0); // Assigns the name of the person who is in the quiz to the word 'who'.
handle = llListen(321,"",NULL_KEY,""); // only need to listen to the dialog
llDialog(who, "Wanna change my outfit?", colours, 321);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(handle); // don't leave listens lying around
if(message == "Red")
{
llSetColor(<1,0,0>, ALL_SIDES);
}
else if(message == "Blue"){
llSetColor(<0,0,1>, ALL_SIDES);
}
else if(message == "Green")
{
llSetColor(<0,1,0>, ALL_SIDES);
}
}
}

jamieparsons Lemon
undergrad n00b
Join date: 5 Nov 2008
Posts: 36
11-20-2008 14:13
Thanks for your help everyone... n when you said "do it like this" did you mean the code brackets or did you actually change something :)
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
11-20-2008 15:17
Well I did delete 2 of the 3 listens,
started to listen after the prim is touched for there's no need for a listen if there's no dialog to listen to and ended to listen when the dialog has answered.

It's also good practise to put a timer in there to end the listen after a set time for when the user chooses to click 'ignore' on the dialog.

The code brackets are there for Firefox users to see the correct indentation.