Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why won't this Menu display?

Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
09-25-2007 12:50
Hi guys,

I have a problem with a menu displaying. The relevant sections of code are below. The first menu appears no problem, and if I select the second option on that menu (Select) I branch to the state to deal with that, which produces another menu with further options. But this second menu will just not display, the script freezes, and I have to reset the script manually from the Tools menu. Strange thing is, in LSLEditor it displays perfectly, and no errors are reported. Can anyone spot anything?

list mmMENU = ["Create", "Select", "List all"]; // the marker maker menu list
default
{
state_entry()
{
llSetAlpha(0.0, ALL_SIDES); //Make all sides transparent
llListen(mychannel, "", NULL_KEY, "";); // listen for dialog answers (from multiple users)
}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "\nCreate - Create a new marker \nSelect - Select a marker to deploy \nList - List all the markers in the database", mmMENU, mychannel);
}

listen(integer channel, string name, key id, string message)
{
if (message == "Create";) state create;
else if (message == "Select";) state select;
else if (message == "List all";) state listall;
}
}



state select
{
state_entry()
{
llListen(mychannel, "", NULL_KEY, "";); // listen for dialog answers (from multiple users)
llDialog(llDetectedKey(0), "\nChoose a marker to be deployed..", mmMENU, mychannel);
state finishUp;
}
listen(integer mychannel, string name, key id, string message)
{
}
}
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
09-25-2007 12:53
llDetectedKey(0) is only defined in certain events (like in touch_start). Once you go into the select state, it is no longer valid.

So when you are in the default state touch_start, set some global variable equal to llDetectedKey(0). Then use that global variable for the llDialog in the select state, instead of using llDetectedKey(0) there.

(You could also set it to the key id from the listen event, but because of the way your overall logic flows, I think the llDetectedKey(0) would be the best.)
Resolver Bouchard
Registered User
Join date: 19 Jul 2006
Posts: 89
09-25-2007 13:00
llDetectedKey() won't return a valid value for the second listen, it only works for certain events such touch_start.

I guess the options are using a global variable to store the key or to call llDialog before you change state.
Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
09-25-2007 16:41
That was it guys, many thanks

I set a global variable,
key dk;

I initialised it with the value after the first llDetectedKey(0), then used dk as the key for subsequent llDialog calls. All works perfectly now.

Thanks again

Rock