CODE
//Simple example of generating multiple sequential dialog menus. There are other ways of doing this, using separate channels.
//Free to use however you want
//Thanks to Osgeld Barmy for stearing me this direction.
//Written by Tex Armistice
//General globals
key USERKEY;
integer CHANNEL = 90;
//Dialog #1 related globals
string strGDialogMsg1 = "Select Item for Dialog #1";
list lstGMenu1 = ["Item 4", "Item 5", "Item 6", "Item 1", "Item 2", "Item 3"];
string strGDialogSelection1;
//Dialog #2 related globals
string strGDialogMsg2 = "Select Item for Dialog #2";
list lstGMenu2 = ["Item A", "Item B", "Item C"];
string strGDialogSelection2;
init()
{
// Clear Variables
strGDialogSelection1 = "";
strGDialogSelection2 = "";
}
default
{
//The following two states initialize the object
state_entry()
{
init();
}
on_rez(integer start_param)
{
init();
}
touch_start(integer total_number)
{
//Get User Key for later use in dialogs
USERKEY = llDetectedKey(0);
//Go to First Dialog
state GetDialog1;
}
}
state GetDialog1
{
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
llDialog(USERKEY, strGDialogMsg1, lstGMenu1, CHANNEL);
llSetTimerEvent(30.0);
}
listen(integer channel, string name, key id, string message)
{
strGDialogSelection1 = message;
llSetTimerEvent(0.0);
state GetDialog2; //Move to next dialog or to FinalResults
}
touch_start(integer total_number)
{
//Shouldn't need this, but in case script get's stuck in this state
state default;
}
timer()
{
state TestError; // time out and report error
}
}
state GetDialog2
{
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
llDialog(USERKEY, strGDialogMsg2, lstGMenu2, CHANNEL);
llSetTimerEvent(30.0);
}
listen(integer channel, string name, key id, string message)
{
strGDialogSelection2 = message;
llSetTimerEvent(0.0);
state FinalResults; //Move to next dialog or to FinalResults
}
touch_start(integer total_number)
{
//Shouldn't need this, but in case script get's stuck in this state
state default;
}
timer()
{
state TestError; // time out and report test error
}
}
// This state is used to process results of the dialog menus
state FinalResults
{
state_entry()
{
llSay(0, "Dialog 1 Selection: " + strGDialogSelection1 );
llSay(0, "Dialog 2 Selection: " + strGDialogSelection2 );
state default;
}
touch_start(integer total_number)
{
//Shouldn't need this, but in case script get's stuck in this state
state default;
}
}
state TestError
{
state_entry()
{
llSay(0, "Dialog Message Error");
state default;
}
touch_start(integer total_number) //Shouldn't need this, but in case script get's stuck in this state
{
state default;
}
}