Jump to content

Correct format for preparing complex menus within other menus?


Guest
 Share

You are about to reply to a thread that has been inactive for 4393 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

list ListofBeers = ["Budweiser", "Budlight"];
list ListofWines = ["Red Wine", "White Wine"];
list ListofSodas = ["Pepsi", "Mountain Dew"];


listen(integer channel, string name, key id, string message)
{
	if (llListFindList(Main_Menu, [message]) != -1)
	{
		if (message == "Beers")
		{
			llDialog(id, "Beverages - Beers", ListofBeers, channel);}

		else if (message == "Wines")
		{
			llDialog(id, "Beverages - Wines", ListofWines, channel);}

		else if (message == "Sodas")
		{
			llDialog(id, "Beverages - Sodas", ListofSodas, channel);}

		else
		{
			llGiveInventory(user,message);}

 Okay, the above portion of code is just to give you a general idea of where I'm starting at before I explain what direction I want to take.  By "general idea", I mean THIS FREAKING CODE IS NOT SCRIPT PERFECT AND IS MISSING BRACKETS AND OTHER THINGS, BUT SO FREAKING WHAT? GET OVER IT!

And when I put that above code into use, it works just fine.  What it would do is create a menu with three buttons labeled "Beers", "Wines", and "Sodas".  Clicking on any of those buttons will make a submenu (or new menu screen) appear, with more buttons.  Clicking on any of those new buttons that are labeled "Budweiser", "Budlight", "Red Wine", "White Wine", "Pepsi", and "Mountain Dew" will then cause an ACTION TO TAKE PLACE.  And that action is that the user will receive that drink from the object's contents.  As I said, IT WORKS AS IT SHOULD!!!

But I want to take off into a different direction.  I've eliminated the "else {llGiveInventory(user,message);}" from the script, because there are no items in the object's contents that I want to give.  In fact, what my script does is it reads multiple notecards and stores strings of information into global lists.  So as of now, clicking (example: "Budweiser", "Budlight", "Red Wine", "White Wine", "Pepsi" and "Mountain Dew") will do absolutely nothing.

That's because I want to change the script.  I want to prepare entire menus with "<", ">", custom messages, as well as the use of llOwnerSay or any other function for each of the items in whatever global list I am using, and make entire sub menus that do the same thing.  That's going to be complicated, but I know I can get it done, once I start out simple and figure out how to have sub menus that are different from the bartender scripts.

I've tried a number of things.

Such as:

listen(integer channel, string name, key id, string message)
{
	if (llListFindList(Main_Menu, [message]) != -1)
	{
		if (message == "Beers")
		{
			llDialog(id, "Beverages - Beers", ListofBeers, channel);

			if (message == "Budweiser") // THIS WAS ATTEMPT #1
			{
				llDialog(id, "Budweiser Options", Budweiser, channel);}

			else if (message == "Budlight")  // THIS WAS ATTEMPT #1
			{
				llDialog(id, "Budlight Options", Budlight, channel);}}

		else if (message == "Wines")
		{
			llDialog(id, "Beverages - Wines", ListofWines, channel);}

 And:

listen(integer channel, string name, key id, string message)
{
	if (llListFindList(Main_Menu, [message]) != -1)
	{
		if (message == "Beers")
		{
			llDialog(id, "Beverages - Beers", ListofBeers, channel);}

		else if (message == "Budweiser") // THIS WAS ATTEMPT #2
		{
			llDialog(id, "Budweiser Options", Budweiser, channel);}

		else if (message == "Budlight")  // THIS WAS ATTEMPT #2
		{
			llDialog(id, "Budlight Options", Budlight, channel);}

		else if (message == "Wines")
		{
			llDialog(id, "Beverages - Wines", ListofWines, channel);}

 And:

listen(integer channel, string name, key id, string message)
{
	if (llListFindList(Main_Menu, [message]) != -1)
	{
		if (message == "Beers")
		{
			llDialog(id, "Beverages - Beers", ListofBeers, channel);}

		if (message == "Budweiser") // THIS WAS ATTEMPT #3
		{
			llDialog(id, "Budweiser Options", Budweiser, channel);}

		if (message == "Budlight")  // THIS WAS ATTEMPT #3
		{
			llDialog(id, "Budlight Options", Budlight, channel);}

		if (message == "Wines")
		{
			llDialog(id, "Beverages - Wines", ListofWines, channel);}

 And:

default
{

state_beers //THIS WAS ATTEMPT #4
{

state_budweiser //THIS WAS ATTEMPT #4
{

state_budlight
{ ///////////////////// sorry I don't feel like typing this all out

But basically my problem is that none of this is working.  For using the states, it will not keep the menu open.  So I have to click the HUD twice to get to the new menu screen.  But it also stops working after it gets to the 2nd level of the menu.  So, pretty much states isn't working for me.  Nor did the otehr three things I tried.  I did everything that Haruki Watanabe did in his script example on this site http://forums-archive.secondlife.com/54/45/266523/1.html  Also, he seems a bit of a scripting genius but when I looked at his script example I couldn't help raising my eyebrows a few times cuz certain things seemed sorta .... incorrect?  lol  but I'm a noob, so maybe he is script perfect.  But anyway nothing I am doing is working. 

Is there anyone who can give me a good script format (here on this thread instead of refering me to some wiki pages that I probably already visited) that utilizes only one script?  So I can continue working?  I hate it when I get stumped and stuck like this.  I apologize if any of this wasn't clear.  Everyone had to start somewhere.  So try not to get an attitude okay?  One day I might become a better scripter than you.

EDIT:  Oh, and I forgot I also tried doing what Adriana Caligari suggested in http://forums-archive.secondlife.com/54/04/109923/1.html but it also didn't work as desired.

Link to comment
Share on other sites

Your second try (the one following "And:", not the one following "Such as:") is fine.  You're using else if, so that the script doesn't have to keep chugging through all the incorrect options after it has been satisfied by an early one.  The only thing that's going to make it fail is that most of the messages you are going to receive are not included in the list called Main_Menu, so the topmost if test in the listen event will fail.  So, for the top level menu you can write

if (~llListFindList (Main_Menu,[message]) )

but for the second level, you'll need to test whether the message matches the "Beer" list or the "Wines" list

else if (~llListFindList(List_of_Beers,[message]) )  and

else if (~llListFindList(List_of_Wines,[message]) )

Once you get going, you obviously want the final options in each branch of the if tree to have an actionable outcome (llSay something or llGive something or at least save a result of some kind).  Otherwise, there's no point in doing all the braching if tests.  Also, once you have that logic worked out you'll want to make provision for closing a llListen once the user has made a choice or letting a timer event cancel it. You'll end up with orphaned listens if you don't.

BTW, using the state idea isn't a bad one.  You could make it work easily enough by letting the state_entry event in each state hold the next level of dialogs.  Just be sure that you re-open the llListen in each state, since they will be closed automatically with each state change.  Although states can be clumsy, the advantage of using them is that you know the llListens will be closed and you know that the script will not let a second user break in which the first user is clicking menus.  The touch_start event is only in state default, after all.

I recommend reading through http://wiki.secondlife.com/wiki/DialogMenus carefully and then poking at several scripts in the LSL Library that use multi-level dialogs.  

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4393 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...