“LlDialog”的版本间的差异

来自人工智能助力教育知识百科
跳转至: 导航搜索
(创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: llDialog( key avatar, string message, list buttons, intege…”)
 
Kjf讨论 | 贡献
 
(未显示1个用户的2个中间版本)
第5行: 第5行:
 
|函数名 = Function: llDialog( key avatar, string message, list buttons, integer channel );
 
|函数名 = Function: llDialog( key avatar, string message, list buttons, integer channel );
 
|参数= 参数:
 
|参数= 参数:
*key avatar–avatar UUID that is in the same region
+
*avatar-在同一区域的关键人物头像UUID
*string message–message to be displayed in the dialog box
+
*message-将显示在对话框中的消息
*list buttons–button labels
+
*buttons-button列表标签
*integer channel–output chat channel, any integer value
+
*channel-输出聊天通道,任何整数值
 
 
|返回值= 返回值:Shows a dialog box in the lower right corner of the avatar's screen (upper right in Viewer 1.x) with a message and choice buttons, as well as an ignore button. This has many uses ranging from simple message delivery to complex menu systems.
 
  
 +
|返回值= 返回值:在化身屏幕的右下角(Viewer 1.x的右上角)显示一个对话框,其中有消息和选择按钮,以及一个忽略按钮。它有许多用途,从简单的消息传递到复杂的菜单系统。
  
 
|注意事项=
 
|注意事项=
*This function causes the script to sleep for 1.0 seconds.
+
注意事项
*This function only opens a dialog box. The script must then also register a listener on the same channel using llListen and have a listen event handler to receive the response.
+
*这个函数使脚本休眠1.0秒。
*There is no way by script to kill a dialog box.
+
*这个函数只打开一个对话框。然后,脚本还必须使用llListen在同一个通道上注册一个侦听器,并拥有一个侦听事件处理程序来接收响应。
*There is no way for the script to detect if the user clicked the small ["Ignore"] button (no chat is generated as a result of pressing this button).
+
*没有办法通过脚本杀死一个对话框。
*There is no way to distinguish the input from a dialog box and regular chat made by the same user.
+
*脚本无法检测用户是否单击了小["Ignore"]按钮(按下此按钮不会生成聊天)
**It is important to expect that the response may not be one of the buttons.
+
*无法区分输入内容与同一用户的对话框和常规聊天内容。
*In most cases, the listener will be in the same script as the llDialog, however if not, the distance between the root prim of the listening object and the dialog generating prim becomes a factor. If this distance is greater than 20 meters when a button is pressed, the response will not be heard. See #Limits.
+
**预期响应可能不是其中一个按钮,这一点很重要。
**This limitation affects attachments too if the wearer moves more than 20 meters from where the listener is located. See #Limits.
+
*在大多数情况下,侦听器将与llDialog位于相同的脚本中,但如果不是这样,侦听对象的根prim与生成prim的对话框之间的距离将成为一个因素。如果按下按钮时这个距离大于20米,则不会听到响应。看到#限制。
**If the listener resides in the same script that created the dialog, then the dialog button is heard sim-wide.
+
**如果佩戴者移动距离听话者所在位置超过20米,此限制也会影响附件。看到#限制。
*By default, only one dialog can be displayed per object in the Second Life Viewer. This can be overridden by the ScriptDialogLimitations debug setting in the Viewer.
+
**如果侦听器位于创建对话框的同一脚本中,则对话框按钮在simwide范围内被侦听。
*The dialog response (the generated chat) has its in world location at the root prim's global position.
+
*默认情况下,Second Life查看器中的每个对象只能显示一个对话框。查看器中的ScriptDialogLimitations调试设置可以覆盖这一点。
It can generate a listen event within 20 meters from that position.
+
*对话框响应(生成的聊天)在根prim的全局位置有它的世界位置。它可以在距离该位置20米内生成侦听事件。
*The listening location for a child prim in the object is either at the child prim's location or at the root prim's location
+
*对象中子prim的监听位置要么在子prim的位置,要么在根prim的位置
see bugtrace JIRA SCR-43
+
参见bugtrace JIRA SCR-43
  
 
|示例=
 
|示例=

2021年8月17日 (二) 09:31的最新版本

Template:Needs Translation/


函数名
Function: llDialog( key avatar, string message, list buttons, integer channel );
参数:
  • avatar-在同一区域的关键人物头像UUID
  • message-将显示在对话框中的消息
  • buttons-button列表标签
  • channel-输出聊天通道,任何整数值
返回值:在化身屏幕的右下角(Viewer 1.x的右上角)显示一个对话框,其中有消息和选择按钮,以及一个忽略按钮。它有许多用途,从简单的消息传递到复杂的菜单系统。
注意事项
注意事项
  • 这个函数使脚本休眠1.0秒。
  • 这个函数只打开一个对话框。然后,脚本还必须使用llListen在同一个通道上注册一个侦听器,并拥有一个侦听事件处理程序来接收响应。
  • 没有办法通过脚本杀死一个对话框。
  • 脚本无法检测用户是否单击了小["Ignore"]按钮(按下此按钮不会生成聊天)。
  • 无法区分输入内容与同一用户的对话框和常规聊天内容。
    • 预期响应可能不是其中一个按钮,这一点很重要。
  • 在大多数情况下,侦听器将与llDialog位于相同的脚本中,但如果不是这样,侦听对象的根prim与生成prim的对话框之间的距离将成为一个因素。如果按下按钮时这个距离大于20米,则不会听到响应。看到#限制。
    • 如果佩戴者移动距离听话者所在位置超过20米,此限制也会影响附件。看到#限制。
    • 如果侦听器位于创建对话框的同一脚本中,则对话框按钮在simwide范围内被侦听。
  • 默认情况下,Second Life查看器中的每个对象只能显示一个对话框。查看器中的ScriptDialogLimitations调试设置可以覆盖这一点。
  • 对话框响应(生成的聊天)在根prim的全局位置有它的世界位置。它可以在距离该位置20米内生成侦听事件。
  • 对象中子prim的监听位置要么在子prim的位置,要么在根prim的位置

参见bugtrace JIRA SCR-43

示例
示例1
// When the prim is touched, give the toucher the option of killing the prim.
 
integer gListener;     // Identity of the listener associated with the dialog, so we can clean up when not needed
 
default
{
    touch_start(integer total_number)
    {
        // Kill off any outstanding listener, to avoid any chance of multiple listeners being active
        llListenRemove(gListener);
        // get the UUID of the person touching this prim
        key user = llDetectedKey(0);
        // Listen to any reply from that user only, and only on the same channel to be used by llDialog
        // It's best to set up the listener before issuing the dialog
        gListener = llListen(-99, "", user, "");
        // Send a dialog to that person. We'll use a fixed negative channel number for simplicity
        llDialog(user, "\nDo you wish this prim to die?", ["Yes", "No" ] , -99);
        // Start a one-minute timer, after which we will stop listening for responses
        llSetTimerEvent(60.0);
    }
    listen(integer chan, string name, key id, string msg)
    {
        // If the user clicked the "Yes" button, kill this prim.
        if (msg == "Yes")
            llDie();
        // The user did not click "Yes" ...
        // Make the timer fire immediately, to do clean-up actions
        llSetTimerEvent(0.1);        
    }
    timer()
    {
        // Stop listening. It's wise to do this to reduce lag
        llListenRemove(gListener);
        // Stop the timer now that its job is done
        llSetTimerEvent(0.0);// you can use 0 as well to save memory
    }
}

示例2

string mainMenuDialog = "\nWhich settings would you like to access?\nClick \"Close\" to close the menu.\n\nYou are here:\nMainmenu";
list mainMenuButtons = ["sub 01", "sub 02", "Close"];
 
string subMenu_01_Dialog = "\nClick \"Close\" to close the menu.\nClick \"-Main-\" to return to the main menu.\n\nYou are here:\nMainmenu > sub 01";
list subMenu_01_Buttons = ["action 01a", "action 01b", "Close", "-Main-"];
 
string subMenu_02_Dialog = "\nClick \"Close\" to close the menu.\nClick \"-Main-\" to return to the main menu.\n\nYou are here:\nMainmenu > sub 02";
 
list subMenu_02_Buttons = ["action 02a", "action 02b", "Close", "-Main-"];
 
integer dialogChannel;
integer dialogHandle;
 
open_menu(key inputKey, string inputString, list inputList)
{
    dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1;
    dialogHandle = llListen(dialogChannel, "", inputKey, "");
    llDialog(inputKey, inputString, inputList, dialogChannel);
    llSetTimerEvent(30.0);
}
 
close_menu()
{
    llSetTimerEvent(0.0);// you can use 0 as well to save memory
    llListenRemove(dialogHandle);
}
 
default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    touch_start(integer total_number)
    {
        key id = llDetectedKey(0);
        // Ensure any outstanding listener is removed before creating a new one
        close_menu();
        open_menu(id, mainMenuDialog, mainMenuButtons);
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if(channel != dialogChannel)
            return;
 
        close_menu();
 
        if(message == "-Main-")
            open_menu(id, mainMenuDialog, mainMenuButtons);
 
        else if(message == "sub 01")
            open_menu(id, subMenu_01_Dialog, subMenu_01_Buttons);
 
        else if(message == "sub 02")
            open_menu(id, subMenu_02_Dialog, subMenu_02_Buttons);
 
        else if (message == "action 01a")
        {
            //do something
            open_menu(id, subMenu_01_Dialog, subMenu_01_Buttons);
        }
        else if (message == "action 01b")
        {
            //do something else
 
            //maybe not re-open the menu for this option?
            //open_menu(id, subMenu_01_Dialog, subMenu_01_Buttons);
        }
        else if (message == "action 02a")
        {
            //do something
            open_menu(id, subMenu_02_Dialog, subMenu_02_Buttons);
        }
        else if (message == "action 02b")
        {
            //do something else
            open_menu(id, subMenu_02_Dialog, subMenu_02_Buttons);
        }
    }
 
    timer()
    {
        close_menu();
    }
}
相关函数
llListen

llTextBox llRegionSay llWhisper–Sends chat limited to 10 meters llSay–Sends chat limited to 20 meters llShout–Sends chat limited to 100 meters llInstantMessage–Sends chat to the specified user llOwnerSay–Sends chat to the owner only

相关事件
listen