|
Lucy Zelmanov
Registered User
Join date: 19 Feb 2007
Posts: 178
|
07-16-2008 10:26
Below is a broadcast script I've been working on to change the textures and colors in a non-linked prim. Now I wrote it in LSLEditor 2.37 and it compiles fine in there and runs as it should. However when I create a new script in SL and add the code, it compiles fine but does nothing ? I have a working listner which I wrote so I know thats not the problem, the listner works fine with a simpler menu broadcaster but this one nothing. Any ideas where I've gone wrong ?
integer CHANNEL = 45;
list MENU_MAIN = ["Texture", "Color", "Effects"]; list MENU_TEXTURE = ["Texture1"]; // Texture Submenu list MENU_COLOR = ["White", "Black"]; list MENU_EFFECT = ["On", "Off"];
default { state_entry() { llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users) }
touch_start(integer total_number) { llDialog(llDetectedKey(0), "Menu", MENU_MAIN, CHANNEL); }
listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN + MENU_TEXTURE + MENU_COLOR + MENU_EFFECT, [message]) != -1) // verify dialog choice
{ if (message == "Texture") { llDialog(llDetectedKey(0), "Texture", MENU_TEXTURE, CHANNEL); if (message == "Texture1") llSay(0, "Texture1"); } }
{ if (message == "Color") { llDialog(llDetectedKey(0), "Color", MENU_COLOR, CHANNEL); if (message == "White") llSay(0, "White"); if (message == "Black") llSay(0, "Black"); } }
if (message == "Effects") { llDialog(llDetectedKey(0), "effects", MENU_EFFECT, CHANNEL); llSay(0, name + " picked the option '" + message + "'."); // Effects Menu Selected if (message == "On") llSay(0, name + " picked the option '" + message + "'."); // On Selected if (message == "Off") llSay(0, name + " picked the option '" + message + "'."); // Off Selected } } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-16-2008 10:47
Here's a hint: take a look at your 'if' constructs. The 'message' variable can't be equal to "Texture" and "Texture1" at the same time. No idea why it might test okay outside of SL.
|
|
Lucy Zelmanov
Registered User
Join date: 19 Feb 2007
Posts: 178
|
07-16-2008 10:54
From: Hewee Zetkin Here's a hint: take a look at your 'if' constructs. The 'message' variable can't be equal to "Texture" and "Texture1" at the same time. No idea why it might test okay outside of SL. By rights it shoulden't as the first "Texture" calls a menu so the variable is replaced by Texture1 by the next if statment.
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
07-16-2008 12:01
It's the llDetectedKey(0) bit that ruins it. In the touch event do something like ID = llDetectedKey(0); Then replace the llDetectedKey(0) in all dialogs with ID. Btw. The nesting of the if's in the listen looks wrong to me. Me thinks this is what you're going for: From: someone listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN + MENU_TEXTURE + MENU_COLOR + MENU_EFFECT, [message]) != -1) // verify dialog choice { if (message == "Texture"  llDialog(ID, "Texture", MENU_TEXTURE, CHANNEL); if (message == "Texture1"  llSay(0, "Texture1"  ; if (message == "Color"  llDialog(ID, "Color", MENU_COLOR, CHANNEL); if (message == "White"  llSay(0, "White"  ; if (message == "Black"  llSay(0, "Black"  ; if (message == "Effects"  { llDialog(ID, "effects", MENU_EFFECT, CHANNEL); llSay(0, name + " picked the option '" + message + "'."  ; // Effects Menu Selected } if (message == "On"  llSay(0, name + " picked the option '" + message + "'."  ; // On Selected if (message == "Off"  llSay(0, name + " picked the option '" + message + "'."  ; // Off Selected } }
|
|
Lucy Zelmanov
Registered User
Join date: 19 Feb 2007
Posts: 178
|
07-16-2008 12:24
From: Ron Khondji It's the llDetectedKey(0) bit that ruins it.
In the touch event do something like ID = llDetectedKey(0); Then replace the llDetectedKey(0) in all dialogs with ID.
Btw. The nesting of the if's in the listen looks wrong to me. Me thinks this is what you're going for: Thank You  the id thing worked perfectly. I'll have a look at the code snippet, tho it may take me some time to make sense of it. I'm not realy a coder at heart.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
07-16-2008 12:26
The listen event already supplies you with the key of who said something - I'd just feed that back to the dialog..
edit: also, unless you want people to be able to control this by manually typing stuff in, it's better to use a negative channel number..
_____________________
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
|
|
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
|
07-16-2008 12:53
Also as a tip use "else if" instead of multiple if statements, it stops it having to check every condition once a match is found.
|
|
Wildefire Walcott
Heartbreaking
Join date: 8 Nov 2005
Posts: 2,156
|
07-16-2008 12:54
From: Lucy Zelmanov By rights it shoulden't as the first "Texture" calls a menu so the variable is replaced by Texture1 by the next if statment. ...but the listen event triggered by the embedded dialog box doesn't scan for "Texture1." The dialog box is going to trigger a listen event, not continue running from the point where you called it.
|