Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Menu Problem

Oliviero Ranimo
Registered User
Join date: 19 Jan 2009
Posts: 13
02-26-2009 06:56
Here's the basic script I'm starting with:

// when touched, present a dialog with four color choices

integer CHANNEL = -42; // dialog channel
list MENU_MAIN = ["Effects", "Texture/s", "Theme"]; // the main menu
list MENU_EFFECTS = ["Laser", "Strobe", "Mist", "...Back"]; // a submenu
list MENU_TEXTURES = ["Moon", "Glass", "Flat", "...Back"]; // a submenu
list MENU_THEMES = ["Slow", "Normal", "Fast", "Hip Hop", "Rave", "Smooth", "...Back"]; // a submenu

menuStart(){
llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
}

default {
state_entry() {
llListen(CHANNEL, "", NULL_KEY, "";); // listen for dialog answers (from multiple users)
}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner())
{
menuStart();
}else{
//jump animate;
}
}
listen(integer channel, string name, key id, string message)
{
if (llListFindList(MENU_MAIN + MENU_EFFECTS + MENU_TEXTURES + MENU_THEMES, [message]) != -1) // verify dialog choice
{
llSay(0, name + " picked the option '" + message + "'.";); // output the answer
if (message == "Effects";)
llDialog(id, "Pick an option!", MENU_EFFECTS, CHANNEL); // present submenu on request
else if (message == "Texture/s";)
llDialog(id, "Pick an option!", MENU_TEXTURES, CHANNEL); // present submenu on request
else if (message == "Theme";)
llDialog(id, "Pick an option!", MENU_THEMES, CHANNEL); // present submenu on request
else if (message == "...Back";)
menuStart(); // present main menu on request to go back
} else
llSay(0, name + " picked invalid option '" + llToLower(message) + "'.";); // not a valid dialog choice
}
}


This is basically copied from the Wiki and modified a little by me. What I'm having trouble with is the "Back" option at the bottom of the script. I created the menuStart function in order to save space and time. The initial call to the function at the beginning of the script works fine, but when it is called from the elseIf section it does not load.

What I can't understand is the fact that if I use the llDialog code from the function itself, in place of the function call it works fine. I am a newcomer to LSL scripting so it maybe that I have made a rookie mistake.

Many thanks to anyone who can point out where I may be going wrong.
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
02-26-2009 07:35
Looks like you copied llDetectedKey(0) from touch_start into your menuStart routine. It doesn't do anything outside touch_start. Replace it with llGetOwner() in the llDialog call and your script should work.
_____________________
The Vengeance Studio Gadget Store is closed!

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
02-26-2009 07:41
you might want to also change the listen to owner only. and put a changed event so that the script resets when the owner has changed, or an on rez event so that it resets each time it's rezzed
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Oliviero Ranimo
Registered User
Join date: 19 Jan 2009
Posts: 13
02-26-2009 08:01
@Anya

Thanks that's cleared that up.

@Ruthven

How would I implement the listen to owner only part? The on rez I can do. Thanks for the input.

Would this work?

llListen(CHANNEL, "", llGetOwner(), "";);
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
02-26-2009 10:04
From: Oliviero Ranimo

Would this work?

llListen(CHANNEL, "", llGetOwner(), "";);



yep, that should work perfectly for listening only to the owner.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.