関数: llDialog( key avatar, string message, list buttons, integer chat_channel );
avatarのスクリーンにmessageとbuttonsを加えたダイアログボックスを表示します。
| • key
| avatar
| –
| UUIDのアバタ
|
|
| • string
| message
|
|
|
|
| • list
| buttons
|
|
|
|
| • integer
| chat_channel
|
|
|
|
ボタンが押されたとき、avatarはchat_channel上でボタンのテキストを叫びます。
チャットの位置はダイアログボックスが作られたときのプリムの場所です。
例
integer channel = 1000;
list pairs = [];
default
{
state_entry()
{
llListen(channel,"", "","");
}
touch_start(integer count)
{
llDialog(llDetectedKey(0), "This is a test dialog.\n\nPlease choose one of the below options.",
["Yes", "No", "0", "1"], channel);
}
listen(integer chan, string name, key id, string mes)
{
if(id == llGetOwnerKey(id))//won't listen to objects unless they aren't in the region.
llSay(0,name + " (" + (string)llGetObjectDetails(id, (list)OBJECT_POS) + ") chose option " + mes);
}
}
部分的な利用
//Compact function to put buttons in "correct" human-readable order
integer channel;
list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4)
+ llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}
default
{
state_entry()
{ // Create random channel within range [-1000000000,-2000000000]
channel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
llListen(channel,"", "","");
}
touch_start(integer total_number)
{
llDialog(llDetectedKey(0),"\nPlease choose an option:\n",
order_buttons(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]),channel);
}
listen(integer _chan, string _name, key _id, string _option)
{
llSay(0, _name + " chose option " + _option);
}
}
ノート
大きなマイナス域のチャンネルを使うのはよい手段です。(最大マイナス域での32bit integerで、これ以上はありえないマイナス域とすれば、-2,147,483,64です)
例
// Create random channel within range [-1000000000,-2000000000]
integer channel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
llDialog(llDetectedKey(0), "Please choose one of the below options:",
["Yes", "No", "0", "1"], channel);
マイナスチャンネル上でアバタがチャットをするのは不可能で、幾つかの他のオブジェクトが、なんらかのそのようなチャンネル上で発言してしまう事故は極めてありえないでしょう。(もちろん、故意にメッセージ対象のチャンネル上での'listen'を設定可能です)