Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDialog help please

Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
06-25-2007 13:00
I have a rather old dialog menu made by Zonax Delorean, but it works. It has an engine script and the options script and a notecard that is used for the menus.
What I'm having a problem with is getting the menu to come up again after a selection is made.
In my opinion, all i need to do is to put the command that is used on touch into all the option commands. But its not working. Here is the code for the options. If anybody can point me in the direction I need to go, thank you.

CODE

// Menu demo program

//---Menu Library interface-------------
integer LM_DOMENU = 10001;
integer LM_OPTIONDATA = 10002;
integer LM_MENULOADED = 10003;
integer LM_RESETMENUSYSTEM = 10004;
integer LM_READSTRING = 10005;
integer LM_READSTRINGDATA = 10006;

resetMenu() {
llMessageLinked(llGetLinkNumber(),LM_RESETMENUSYSTEM,"",NULL_KEY);
}
doMenu( key user, string menuname ) {
llMessageLinked(llGetLinkNumber(),LM_DOMENU,menuname,user);
}
readString( key user, string var, string prompt ) {
llMessageLinked(llGetLinkNumber(),LM_READSTRING,var+" "+prompt,user);
}
//---Menu Library interface End----------


default
{
state_entry()
{
}

link_message(integer sender_num, integer num, string str, key id) {
if (num==LM_OPTIONDATA) {
// menu result? let's process it!

if (str=="MCOLOR|Red")
{
llShout (113,"red");
doMenu(llDetectedKey(0),"DEFAULT");
}

if (str=="MCOLOR|Green")
{
llShout (113,"green");
doMenu(llDetectedKey(0),"DEFAULT");
}
if (str=="MCOLOR|Blue")
{
llShout (113,"blue");
doMenu(llDetectedKey(0),"DEFAULT");
}
if (str=="MCOLOR|Purple")
{
llShout (113,"purple");
doMenu(llDetectedKey(0),"DEFAULT");
}
if (str=="MCOLOR|White")
{
llShout (113,"white");
doMenu(llDetectedKey(0),"DEFAULT");
}

}
if (num==LM_MENULOADED) llSay(0,"Menu ready");
}

touch_start(integer total_number)
{
doMenu(llDetectedKey(0),"DEFAULT");
}
}
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
06-25-2007 13:50
llDetectedKey will not return any value inside the link_message event, only in events like touch and collisions.

Try replacing llDectedtKey(0) with key in all of those calls and see if that works for you.
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-25-2007 13:50
Try the following change, just curious if it will work for you. I'm not convinced that you can use llDetectedKey outside of a sensor/touch event. So this may be the problem:


From: Robin Peel

// Menu demo program

//---Menu Library interface-------------
integer LM_DOMENU = 10001;
integer LM_OPTIONDATA = 10002;
integer LM_MENULOADED = 10003;
integer LM_RESETMENUSYSTEM = 10004;
integer LM_READSTRING = 10005;
integer LM_READSTRINGDATA = 10006;
key CurrentUser;

resetMenu() {
llMessageLinked(llGetLinkNumber(),LM_RESETMENUSYSTEM,"",NULL_KEY);
}
doMenu( key user, string menuname ) {
llMessageLinked(llGetLinkNumber(),LM_DOMENU,menuname,user);
}
readString( key user, string var, string prompt ) {
llMessageLinked(llGetLinkNumber(),LM_READSTRING,var+" "+prompt,user);
}
//---Menu Library interface End----------


default
{
state_entry()
{
}

link_message(integer sender_num, integer num, string str, key id) {
if (num==LM_OPTIONDATA) {
// menu result? let's process it!

if (str=="MCOLOR|Red";)
{
llShout (113,"red";);
doMenu(currentUser,"DEFAULT";);
}

if (str=="MCOLOR|Green";)
{
llShout (113,"green";);
doMenu(currentUser,"DEFAULT";);
}
if (str=="MCOLOR|Blue";)
{
llShout (113,"blue";);
doMenu(currentUser,"DEFAULT";);
}
if (str=="MCOLOR|Purple";)
{
llShout (113,"purple";);
doMenu(currentUser,"DEFAULT";);
}
if (str=="MCOLOR|White";)
{
llShout (113,"white";);
doMenu(currentUser,"DEFAULT";);
}

}
if (num==LM_MENULOADED) llSay(0,"Menu ready";);
}

touch_start(integer total_number)
{
currentUser=llDetectedKey(0);
doMenu(currentUser,DEFAULT";);
}
}
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-25-2007 13:52
jinx!

From: Milambus Oh
llDetectedKey will not return any value inside the link_message event, only in events like touch and collisions.

Try replacing llDectedtKey(0) with key in all of those calls and see if that works for you.
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
06-25-2007 15:31
thank you for the hints. i have tried the suggestion. i used currentUser, NULL_KEY and "". the silly menu won't come back up after making a selection. maybe i should just try and make my own from scratch. no. i'll keep at it till i figure out how to make it come back up after making a selection.
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
06-25-2007 16:17
From: Shadow Subagja
Try the following change, just curious if it will work for you. I'm not convinced that you can use llDetectedKey outside of a sensor/touch event. So this may be the problem:

Forgot the " in the last doMenu(currentUser,DEFAULT";);
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-25-2007 17:52
the if tree in this script makes me shudder
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-25-2007 20:05
Yeah, to that point one really easy speed enhancement would be the 'else' keyword. Ie you can change an:
if() blah;
if() blah;
if() blah;

to:

if() blah;
else if() blah;
else if() blah;

In this case since you only intend to deal with one of these at a time, this will cut down the number of string compares to about half on average since it will only walk the list until it has succeeded, then skip anything prefixed with an else after that. Not really a big deal in a menu system as they are given oodles of time to process while waiting for fingers to click mice, but still.. good habit to get into.

A better habit to get into would be to have defined both sides of the interface using integers which are fast to compare:
integer MCOLOR_RED = 10101;

if(num == MCOLOR_RED) blah;

But you're sort of at the mercy of the existing script here.