Understanding Dialogs
The Linden Scripting Language allows much more direct interaction with avatars than simple touch events. It is also possible to create a dialog. A Second Life dialog can be seen in Figure 6.2.
Figure 6.2: Second Life Dialogs

The following script makes use of a dialog that is Mark Biss2007-12-12T00:00:00Not sure hereto allow the user to select a color. This can be seen in Listing 6.3.
Listing 6.3: A Second Life Dialog
integer CHANNEL = 10;
default
{
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
}
touch_start(integer total_num)
{
list l = ["red","green","blue"];
key who = llDetectedKey(0);
llDialog(who, "Where to?", l, CHANNEL);
}
listen(integer channel, string name, key id,
string message)
{
if( llToLower(message) == "red" )
{
llSetColor(<255,0,0>,ALL_SIDES);
}
else if( llToLower(message) == "green" )
{
llSetColor(<0,255,0>,ALL_SIDES);
}
else if( llToLower(message) == "blue" )
{
llSetColor(<0,0,255>,ALL_SIDES);
}
}
}
This script is very similar to the script presented in the last section. There are two main differences. First, this script makes use of channel 10, rather than channel zero. The second difference is that this script makes use of a dialog.
The dialog is used at the end of the touch_start event handler. Calling the llDialog function creates a dialog. The dialog will display buttons that correspond to the list that was passed into the llDialog function.
Once the user selects one of the options from the dialog, the name of that button is “said” over the specified channel. This causes the user's choice to be picked up by the listen event handler. In this way, implementing a dialog is very similar to implementing a script that listens to user conversation.




