Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Simple method of generating multiple sequential dialog menus

Tex Armistice
Registered User
Join date: 13 Dec 2005
Posts: 20
05-24-2006 20:47
Below is a generic sample of generating multiple sequential dialog menus. The menus are generated in separate states, with a final state to handle processing of the user's selections. Thanks to Osgeld Barmy for suggesting this route over in the scripting forum.

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;
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
05-27-2006 16:17
/15/b3/108952/1.html
_____________________
i've got nothing. ;)
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
05-27-2006 17:53
hehe thanks for the cred :)

altho its ironic becuase ive never used mutiple states for dialog in world, why? basicly becuase im hard headed, and like to make things more complicated than they should be