Jump to content

Multiscript Top Menu


Parasite Palen
 Share

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

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

Recommended Posts

Hey all.

 

So I'm making an item with multiple scripts that will start on touch, but I don't want several menus popping up. Have had problems with this in the past on stuff I've bought.

 

I'm not that good at scripting but have some basic knowledge and can understand or adapt some scripts to my needs.

 

Is it possible to create one menu which links to the other menus? A top menu so to speak with a button to select which of the on-touch menus I actually want to mess with.

Would this require editing the other scripts to take out the touch start?

 

Pointing me to the appropriate place to learn for myself would be as much appreciated as it being explained.

Thanks in advance.

Link to comment
Share on other sites

Indeed, there are many of us that do that.  And several approachs to accomplish it, depending on whether or not your menus are static (like sitting position in a hot tub) or dynamic (radio stations).

 

The simple solution when you know your menu structure and know it won't change is to have a list of the menus with a different suffix.  Like:

 

integer menuSelect = 0;

list menu0 = ["1", "2", "3"];

list menu1 = ["a", "b", "c"];

list menu2 = ["d", "e", "f"];

list menu3 = ["g", "h, "i"];

 

When touched, the menuselect is set to 0 and you llDialog the menu0.  Select 1, and you then llDialog the menu1.  Etc etc. 

 

for dynamic menus, you generate a temporary list of the data you need upon reciept of command for that menu.  Then you insert list items for Next and Prev into it.  Pressing Next increases a counter by 10 and remakes the list starting at that counter, again adding the Prev and Next items.  Prev decrements by 10 and repopulates the list going out to the llDialog.  This is more complex but if you make a subroutine MakeList(menunum, startfrom) that returns the list to throw out to llDialog, it's quite compact.

 

Link to comment
Share on other sites

The Scripting Library is a place to look for scripts or to post a script that you have written and want to share. If you are writing a script and can use some help, the place to post your question is the Scripting Forum. If you are looking for someone to write a script for you, the best place to ask is in the Inworld Employment section of the Commerce Forums (http://community.secondlife.com/t5/Inworld-Employment/bd-p/InworldEmployment). You will have much better luck.

Link to comment
Share on other sites

now that it's in the right place...

what you would do is to change all the sub menu scripts to trigger when they receive a specific link message rather than a touch, then have your master menu trigger on touch, and each menu button will cause a different link message to be sent, triggering the menu's of the sub menu scripts

Link to comment
Share on other sites

One thing an inexperienced scripter may not at first realise, (I didn't and I still remember it driving me almost to tears trying to figure out what was wrong) is that when you pass the link message to the submenu scripts, you have to have something like this in the receiver script:

 

link_message(integer sender_number, integer number, string message, key id)	{		handle = llListen(dialog_channel,"",id,"");		llDialog(id,"Please choose an option",choices,dialog_channel);		//llDialog(llDetectedKey(0),...) won't work in link messages!)	}

 

 

 

 

 

Link to comment
Share on other sites

I'm too late for that parade again, these women are quick (and I owe Darkie another L$0) but I will add the standard meta-comment:

"I'm making an item with multiple scripts that will start on touch" - do you really need to?

Although the changes needed as outlined above are not major they are not trivial either.  You may wish to re-think your strategy, especially as fewer scripts are still desirable even though script-limits have been dropped.  It can often be a lot easier to have a single script that handles all the user-communications, along with the timing, listens, etc.  If practical move as much of the processing as possible into that script as well and get rid of the multiple scripts.  Where necessary, ie; you're out of memory, send a link-message to your sub-script saying 'perform this function'.

Link to comment
Share on other sites

Ok firstly my apologies for it having been in the wrong place though it showed in the right place for me. Forums / Content Creation / LSL Scripting / 

Where was it?

 

Thanks for all your help. I'm actually going to do as suggested and rethink my strategy on this. Still early days yet.

I appreciate everybody's help and will look further into all the information given.

 

Thanks loads.

Link to comment
Share on other sites

 


Parasite Palen wrote:

Where was it?

it was in the "LSL Scripting Library", which is only for completed scripts that are being offered to the community... I think I'm going to go ask that they rename it to "LSL Library" to reduce that confusion, so that it's not as easy to make that mistake

 

Link to comment
Share on other sites

Since you're re-thinking your approach, you might want to consider putting all the sub-menus into one script (which is what I would tend to do).

The basic mechanism is something like this:

 

list top_level_menus=    [        "Reds",    "Blues",    "Greens"        ];list reds=    [        "Dark Red",    "Medium Red",    "Light Red"        ];list blues=    [        "Dark Blue",    "Medium Blue",    "Light Blue"        ];list greens =    [        "Dark Green",    "Medium Green",    "Light Green"        ];list buttons;integer handle;integer dialog_channel;float timeout =30.0;key toucher = NULL_KEY;string caption;list order_buttons(list buttons)//compact function to put buttons in readable order{    return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4)        + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);}default{    state_entry()    {        dialog_channel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;        //quick way to calculate a channel based on the prim's uuid -- almost certain to be unique on the sim    }    touch_start(integer total_number)    {        if(llDetectedKey(0)!=toucher){            if(toucher==NULL_KEY){//if I'm not in use by anyone                toucher = llDetectedKey(0);//now i am            }            else{//I am in use                llRegionSayTo(llDetectedKey(0),0,"Sorry, but the item is in use right now");//so let's use a new function to say I am                return;//and don't do anything else            }        }        llListenRemove(handle);//close any old listeners that might be open still        handle=llListen(dialog_channel,"",toucher,"");//listen to the toucher on the dialog channel        buttons = ["Finished"]+top_level_menus;        caption = "Please choose a colour group";        llDialog(toucher,caption,order_buttons(buttons),dialog_channel);        llSetTimerEvent(timeout);//30 seconds to choose    }    listen(integer channel, string name, key id, string msg)    {        if("Finished"==msg){//if we've finished            llListenRemove(handle);//stop listening            llSetTimerEvent(0.0);//turn off the timer            toucher=NULL_KEY;//clear the "toucher" variable so we're ready for the next person            return;        }        else if ("Main Menu"==msg){            caption = "Please choose a colour group";            buttons = ["Finished"]+top_level_menus;        }        else if(~llListFindList(top_level_menus,[msg])){//if the message is one of the items in the list top_level_menu            buttons =["Finished"]+["Main Menu"];            if("Reds"==msg){//choose the appropriate choices for the next menu we present                buttons+=reds;            }            else if("Blues"==msg){                buttons+=blues;            }            else if ("Greens"==msg){                buttons+=greens;            }            caption = "Please choose a colour shade";        }        else if(~llListFindList(reds,[msg])){            llRegionSayTo(id,0,"You chose one of the reds, and your choice was "+msg);            //this is where you would do something with the menu choice        }        else if(~llListFindList(blues,[msg])){            llRegionSayTo(id,0,"You chose one of the blues, and your choice was "+msg);            //this is where you would do something        }        else if(~llListFindList(greens,[msg])){            llRegionSayTo(id,0,"You chose one of the greens, and your choice was "+msg);            //this is where you would do something        }        llDialog(toucher,caption,order_buttons(buttons),dialog_channel);        llSetTimerEvent(timeout);//30 seconds to choose    }    timer()//always do this in dialogs, in case the toucher has hit "ignore" or crashed or wandered off    {        llListenRemove(handle);//stop listening        llSetTimerEvent(0.0);//turn off the timer        toucher=NULL_KEY;//clear the "toucher" variable so we're ready for the next person    }}

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4709 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...