// to handle multiple menus in a items.
// This consists of 2 scripts The first one is the primary control script.
Primary Control Script
CODE
string main = "Title Goes Here\nWhat Would you Like to do?";
integer debug = FALSE;
string command1 = "A"; //This is the text displayed on the opt1 button of the menu, you can add more if you like
string command2 = "B"; //This is the text displayed on the opt2 button of the menu, you can add more if you like
integer coms_chan = 129834765;
integer menu_chan = 129834766; //Add additonal channels if you want to add multiple sub menus. Make certain to change the Listen area to compensate for additional sub menus
integer prim = LINK_THIS;
list main_options = [command1,"EXIT",command2];
integer listening;
integer sys_chan;
key Toucher;
key owner;
string Oname;
string gUser;
menu_main(key id)
{
llListenRemove(listening);
sys_chan = (integer)llFrand(-2000000000);
listening = llListen(sys_chan,"",id,"");
llListenControl(listening,TRUE);
llDialog(id,"Welcome: "+Oname+"\n"+main,main_options,sys_chan);
}
function1(string message)
{ llSay(0,"Something for Function 1 goes here"); }
default
{
on_rez(integer r)
{
llResetScript();
}
state_entry()
{
owner = llGetOwner();
Oname = llKey2Name(llGetOwner());
}
touch_start(integer total_number)
{
Toucher = llDetectedKey(0);
gUser = llDetectedName(0);
if (Toucher == owner)
{
listening = llListen(sys_chan,"",owner,"");
menu_main(owner);
llSetTimerEvent(0.0);
}
}
link_message(integer send, integer ch, string str, key id)
{
if ( ch == coms_chan )
{
sys_chan = (integer)llFrand(-2000000000);
listening = llListen(sys_chan,"",id,"");
menu_main(id);
}
}
listen(integer ch, string name, key id, string msg)
{
if ( ch == sys_chan )
function1(msg);
}
}
now for the secondary response script
CODE
// --~<[[ DemoniX DesignZ Inc. ]]>~-- Menu Interfacer Responder:
// Created: 12/29/2006
// Modified Several Times since then.
// Scripted By: Noble Barnes of DemoniX DesignZ
// So here goes, after reviewing several pose scripts and seeing that not one in particular
// was actually able to do everything I needed it to do, so I went ahead and created this.
// this is released under free trade, do with it as you wish, I do however ask that you respect the following terms
// 1.) If you use this code please allow it to be atleast mod/copy/no trans
// 2.) Please leave this header intact.
// 3.) If you use this script and like it, donate 1L$ to Noble Barnes.
// 4.) You can use this script to sell your items, but don't sell this script please.
// 5.) Don't expect any technical assistance with this script.
// 6.) This is released 'as is', it works just fine, read the headings they tell you what to do.
// 7.) Don't IM me asking for help with this script. its FREEWARE for that reason, no support included, I will do a custom version if you need one though.
//
// I create allot of menu driven systems and I think that this happens to be the the best way
// to handle multiple menus in a items.
// This consists of 2 scripts The first one is the primary control script.
string title = "Title Text Goes Here";
string command1 = "A";
string command2 = "B";
list options = [command1,"BACK",command2];
integer prim = LINK_THIS;
integer coms_chan = 129834765; //This channel should match that in the primary control script
integer menu_chan = 129834766; //Change channel if you have multiple sub menus in the primary control script.
integer debug = FALSE;
integer listening;
integer sys_chan;
menu_main(key id)
{
llListenRemove(listening);
sys_chan = (integer)llFrand(-2000000000);
listening = llListen(sys_chan,"",id,"");
llListenControl(listening,TRUE);
llDialog(id,title,options,sys_chan);
}
function1()
{ llSay(0,"Something for Function 1 goes here"); }
function2()
{ llSay(0,"Something for Function 2 goes here"); }
default
{
link_message(integer prim, integer ch, string str, key id)
{
if ( ch == menu_chan )
{
menu_main(id);
}
}
listen(integer ch, string name, key id, string msg)
{
llListenControl(listening,FALSE);
if (debug)
llOwnerSay(llGetScriptName()+" received: "+msg+" command");
if (msg == "BACK") { llMessageLinked(prim, coms_chan, msg, id); }
if (msg == command1) { function1(); }
if (msg == command2) { function2(); }
}
}
this makes it so you can have one controller script and if you want to add multiple settings functions you can have one control menu with up to 9 sub menus.
Hope you found this helpful.
Sincerest Regards;
Noble Barnes
Owner: DemoniX DesignZ Inc.
Edited On: 24 JAN 2008 to add notes about how to add additional sub menu's and to inform people they can pick up a working copy of this script at my store in Second Life at:
http://slurl.com/secondlife/Stipe/141/136/92


...