Jump to content
Sign in to follow this  
Kolby Nissondorf

Please help! How to get menu options to prompt a new menu

Recommended Posts

Okay, so what I am scripting is a HUD, that when a menu item is chosen, it will display a text and/or emotes into local chat.

I have how to do that down (llSay after the menu option.)

What I want to do is organize my options to make it easier to choose what you want to say in local.

What I have so far for the main menu option choices are: (Red is what I would like to happen)

 

else if (choice == "Example1") { ((Perhaps another script here that will prompt a menu for further options to choose from that includes a back button.))   //does something        

llListenRemove(listen_id)

 

I figured I could just find a way to paste the menu script into each indivual option, but that seems like a lot of work.

Any help/Examples would be amazing! Thanks :)

 

-Kolby

Share this post


Link to post
Share on other sites

Is this the sort of thing you mean?

integer handle;list buttons;list MainMenu = ["Reds","Greens","Blues";list reds = ["Dark Red","Medium Red","Light Red"];list greens = ["Dark Green", "Medium Green", "Light Green"];list blues = ["Dark Blue", "Medium Blue", "Light Blue"];key av;default{	state_entry()	{		llSay(0, "Hello, Avatar!");	}	touch_start(integer total_number)	{		av=llDetectedKey(0);		llListenRemove(handle);		handle = llListen(99,"",av,"");		llSetTimerEvent(20.0);		buttons = MainMenu;		llDialog(av,"Please choose a colour",buttons,99);	}	listen(integer channel, string name, key id, string message)	{		llSetTimerEvent(20.0);		if(~llListFindList(MainMenu,[message])){			if("Reds"==message){				buttons=reds;			}			else if ("Blues"==message){				buttons=blues;			}			else if ("Greens"==message){				buttons=greens;			}			llDialog(av,"Please choose one of the "+llToLower(message),buttons+["Back"],99);		}		else if ("Back"==message){			buttons = MainMenu;			llDialog(av,"Please choose a colour",buttons,99);		}		else{//it must be from a sub-menu			llListenRemove(handle);			llRegionSayTo(av,0,"Your choice was "+message);			//here you would do something with the colour choice		}	}	timer()	{		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

Share this post


Link to post
Share on other sites

For some reason, I still cant program it to say an Emote in local when I select an option from the menu.

Say I wanted one to say "/me blows a kiss."

and its location would be Reds button > Dark Red. After selecting those options, it would cause the hud to say "Example HUD blows a kiss."

 

How is this possible?

 

(( & sorry, I'm still new to scripting.)) 

Share this post


Link to post
Share on other sites

Does this example make it any clearer?

integer handle;list buttons;list MainMenu = ["Reds","Greens","Blues","Emote"];list reds = ["Dark Red","Medium Red","Light Red"];list greens = ["Dark Green", "Medium Green", "Light Green"];list blues = ["Dark Blue", "Medium Blue", "Light Blue"];list emotes = ["Blow Kiss", "Blink","Smile"];string my_name;key av;default{    state_entry()    {        my_name = llGetObjectName();    }    touch_start(integer total_number)    {        av=llDetectedKey(0);        llListenRemove(handle);        handle = llListen(99,"",av,"");        llSetTimerEvent(20.0);        buttons = MainMenu;        llDialog(av,"Please choose a colour",buttons,99);    }    listen(integer channel, string name, key id, string message)    {        llSetTimerEvent(20.0);        if(~llListFindList(MainMenu,[message])){            if("Reds"==message){                buttons=reds;            }            else if ("Blues"==message){                buttons=blues;            }            else if ("Greens"==message){                buttons=greens;            }            else if ("Emote"==message){                buttons = emotes;            }            llDialog(av,"Please choose one of the "+llToLower(message),buttons+["Back"],99);        }        else if ("Back"==message){            buttons = MainMenu;            llDialog(av,"Please choose a colour",buttons,99);        }        else{//it must be from a sub-menu            llListenRemove(handle);            if(~llListFindList(emotes,[message])){                llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name                string str;                if("Blow Kiss"== message){                    str = "blows a kiss";                }                else if ("Blink"==message){                    str = "blinks";                }                else if ("Smile"==message){                    str = "smiles";                }                llSay(0,"/me "+str);                llSetObjectName(my_name); //change back            }            else{                llRegionSayTo(av,0,"Your choice was "+message);                //here you would do something with the colour choice            }        }    }    timer()    {        llListenRemove(handle);        llSetTimerEvent(0.0);    }}

 

 

Share this post


Link to post
Share on other sites

Its perfect, but when I try to add in another option for "Thank you" emotes, I modified the original one you gave me

else{  //it must be from a sub-menu
llListenRemove(handle);
 if(~llListFindList(emote,[message])){
llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name
string str;
 if("Thank"== message){ 

 

which I modified to

else{//it must be from a sub-menu
llListenRemove(handle);
 if(~llListFindList(thank,[message])){
llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name
string str;
if("Blow Kiss"== message){ 

I get a Syntax Error from the "timer()" command towards the end of the script. 

I figured if I removed the llListenRemove, it might fix it, but I didnt want to break it without posting here first (since it probably wouldnt work anyways.)

 

Thanks. 

Share this post


Link to post
Share on other sites

You do have a list named emotes, but you don't have one named thank.  You'll never be able to get

if(~llListFindList(thank,[message])

to be true, since it's looking for message in a list that doesn't exist.  Refer to the WIKI for the proper syntax for llListFindList and all other LSL functions. 

The error message that you are getting near the timer event has nothing to do with that, though. That's happening because you have mismatched { } brackets.  I can see that you opened one with your new if("Thank" == message){ statement, but my bet is that you never closed it.  The compiler got all the way to the end of the listen event looking for it and finally gave up looking.

 

Share this post


Link to post
Share on other sites

I think you are going to need to post the full script.   We're glad to help, but without the full script, it's just a guessing game.  If you post the whole thing, we should be able to spot the problem area pretty fast.

Share this post


Link to post
Share on other sites

Good.  As I said, though, that's incidental to the error message you're getting.  Chances are pretty high that you are getting the error message that you asked about because you have mismatched brackets.

Share this post


Link to post
Share on other sites
integer handle;list buttons;list MainMenu = ["Emote","Thank Emotes"];list thank = ["Thank1","Thank2","Thank3"];list emotes = ["Blow Kiss", "Wink","Example4","Example5","Example6","Example7","Example8", "Example9","Example10"];string my_name;key av;default{    state_entry()    {        my_name = llGetObjectName();    }    touch_start(integer total_number)    {        av=llDetectedKey(0);        llListenRemove(handle);        handle = llListen(99,"",av,"");        llSetTimerEvent(20.0);        buttons = MainMenu;        llDialog(av,"Please choose an option",buttons,99);    }    listen(integer channel, string name, key id, string message)    {        llSetTimerEvent(20.0);        if(~llListFindList(MainMenu,[message])){            if("Thank Emotes"==message){                buttons=thank;            }            else if ("Blues"==message){                buttons=blues;            }            else if ("Greens"==message){                buttons=greens;            }            else if ("Emote"==message){                buttons = emotes;            }            llDialog(av,"Please choose one of the "+llToLower(message),buttons+["Back"],99);        }        else if ("Back"==message){            buttons = MainMenu;            llDialog(av,"Please choose a colour",buttons,99);        }        else{//it must be from a sub-menu            llListenRemove(handle);            if(~llListFindList(emotes,[message])){                llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name                string str;                if("Blow Kiss"== message){                    str = "blows a kiss";                }                else if ("Wink"==message){                    str = "examplegoeshere";                }                else if ("Example4"==message){                    str = "examplegoeshere";                }                else if ("Example5"==message){                    str = "examplegoeshere";                }                else if ("Example6"==message){                    str = "examplegoeshere";                }                else if ("Example7"==message){                    str = "examplegoeshere'";                }                else if ("example8"==message){                    str = "examplegoeshere.";                }                else if ("Example9"==message){                    str = "example goes here";                }                else if ("Example10"==message){                    str = "Example goes here";                }               llSay(0,"/me "+str);                llSetObjectName(my_name); //change back            }            else{                llRegionSayTo(av,0,"Sending this emote to local: "+message);                //here you would do something with the colour choice            }        }    }    timer()    {        llListenRemove(handle);        llSetTimerEvent(0.0);    }}

 Heres the script.

Where would I add in:

else{//it must be from a sub-menu            llListenRemove(handle);            if(~llListFindList(emotes,[message])){                llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name                string str;

 to avoid getting an error, and to allow everything to function properly

((sorry if the examples get confusing, I just needed to replace some of the things the emotes would have said, heh.)) 

 



Share this post


Link to post
Share on other sites

All you need to do to make that script compile is take out the lines

  else if ("Blues"==message){                buttons=blues;            }            else if ("Greens"==message){                buttons=greens;            }

 They'll make it throw an error because you don't, in your example, have a list anywhere defined called blues or greens.

Share this post


Link to post
Share on other sites

I removed those now.

Where do I add in my

 else{//it must be from a sub-menu            llListenRemove(handle);            if(~llListFindList(thank,[message])){                llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name                string str;                if("Dark Red"== message){                    str = "You have chosen dark red";                }

 

 & so on, in my script to avoid getting the sytax error again?

Share this post


Link to post
Share on other sites

I don't quite understand the problem.   Here's the structure of the script, at least if I've properly understood what you're trying to do.

Why not put together a basic version of the script as you want it, rather than with these meaningless placeholders, and post that if you're still having difficulty?   That way the logic of what you want the script to do would be clearer, and I think you would find it easier to understand, too

 

integer handle;list buttons;list MainMenu = ["Emote","Thank Emotes"];list thank = ["Thank1","Thank2","Thank3"];list emotes = ["Blow Kiss", "Wink","Example4","Example5","Example6","Example7","Example8", "Example9","Example10"];string my_name;key av;default{	state_entry()	{		my_name = llGetObjectName();	}	touch_start(integer total_number)	{		av=llDetectedKey(0);		llListenRemove(handle);		handle = llListen(99,"",av,"");		llSetTimerEvent(20.0);		buttons = MainMenu;		llDialog(av,"Please choose an option",buttons,99);	}	listen(integer channel, string name, key id, string message)	{		llSetTimerEvent(20.0);		if(~llListFindList(MainMenu,[message])){			if("Thank Emotes"==message){				buttons=thank;			}			else if ("Emote"==message){				buttons = emotes;			}			llDialog(av,"Please choose one of the "+llToLower(message),buttons+["Back"],99);		}		else if ("Back"==message){			buttons = MainMenu;			llDialog(av,"Please choose a colour",buttons,99);		}		else{//it must be from a sub-menu			llListenRemove(handle);//stop listening			if(~llListFindList(emotes,[message])){//whatever the message is, it's from the "emotes list"				llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name				string str;				if("Blow Kiss"== message){					str = "blows a kiss";				}				else if ("Wink"==message){					str = "examplegoeshere";				}				else if ("Example4"==message){					str = "examplegoeshere";				}				//and so on				llSay(0,"/me "+str);				llSetObjectName(my_name); //change back			}//end of what to do if it's something from the emotes list			else if (~llListFindList(thank,[message])){//it's one of the messages from the "thank" list //so do whatever you want .. no need to turn the listener off, //because you did that as soon as you discovered it was a message from a sub menu				llRegionSayTo(av,0,"Sending this emote to local: "+message);			}		}	}	timer()	{		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

Share this post


Link to post
Share on other sites

I suggest stepping back, taking a deep breath, and looking at what you want the script to do.

I'd estimate that 90% of the work in scripting is logic.  Only about 10% is dealing with syntax.  To write a script that works, take the time to draw yourself a flow map so that you see on paper what happens at each decision point in the script you are about to write.  Look at each branch where you have an if condition and ask what happens if the condition is TRUE and what happens if it is FALSE.  Ask how the flow of activity is likely to proceed from one event to another, and anticipate where the script may get hung up if the flow is interrupted.  THEN sit down to write the script.  When you've written enough scripts, you can develop that flow map in your head, but it's always important to have it somewhere or you'll be wasting your time writing code that doesn't do what you want.

Share this post


Link to post
Share on other sites

Okay, so this is what i'm dealing with.

main screen.png

When a user selects the emotes option, they are prompted with the menu you have helped me script so far.

Heres what it looks like:
script dialog.pngWhen a user clicks Emote, it prompts them with the Blow kiss, Wink, etc etc. that you have helped me script.

What I want to do is add in a second button that allows for a new menu to be prompted, in a similar way that happens when clicking the Emote button.

Thats why I need to know where to add this in:

 else{//it must be from a sub-menu            llListenRemove(handle);            if(~llListFindList(thank,[message])){                llSetObjectName(llGetDisplayName(id));//change the object's name to the user's display name                string str;                if("Dark Red"== message){                    str = "You have chosen dark red";                }

 

 to avoid getting any sort of error.....

I think its fairly simple what i'm trying to do, but I am still very new to scripting.

/me takes a deep breath.

 

Sorry if i'm really confusing D:

I really appreciate your guys' help though 

Share this post


Link to post
Share on other sites

How about right where Innula has this, only put your selection of messages where she has the llRegionSayTo ....

			else if (~llListFindList(thank,[message])){//it's one of the messages from the "thank" list //so do whatever you want .. no need to turn the listener off, //because you did that as soon as you discovered it was a message from a sub menu				llRegionSayTo(av,0,"Sending this emote to local: "+message);

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...