LlListen

来自人工智能助力教育知识百科
Ty讨论 | 贡献2020年8月22日 (六) 02:24的版本 (创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名 = Function: integer llListen( integer channel, string name, key id, st…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: integer llListen( integer channel, string name, key id, string msg );
参数:

integer channel – input chat channel, any integer value (-2147483648 through 2147483647) string name – filter for specific prim name or avatar legacy name key id – filter for specific group, avatar or prim UUID string msg – filter for specific message

返回值:

返回一个句柄(整数) ,该句柄可用于禁用或删除 listen。

注意事项
*在通道0[1]和调试通道上发送的消息被限制为每个所有者 / 用户每个区域200 / 10秒。
一旦速率超过,通道零或调试通道上的所有以下消息将被删除,直到前10秒的发送速率再次低于200 / 10秒。 删除消息,尽管被删除,仍然计算在限制之内。
  • 在状态更改或脚本重置时,所有监听都会自动删除
状态更改可用作发布监听的快捷方式
  • 只有65个监听器可以同时在任何一个脚本中打开。
如果这个数字超出了脚本运行时错误的范围,并且发生了太多的侦听错误。
  • 在一段时间内,官方 sl 浏览器和几个第三方浏览器可以像其他非零频道一样直接使用聊天栏中的负频道。 以前,标准的 sl 阅读器只能通过 lldialog 或 lltextbox 响应在负面通道上发送聊天,这意味着负面通道最适合不需要直接的虚拟聊天的应用程序。
  • 聊天的公共频道和积极的渠道被截断为1023字节。 负通道上的聊天被截断为254字节。
  • 一旦注册了监听,它的过滤器就无法更新,如果监听注册在 llgetowner 名下,那么监听在所有者更改时仍然注册在原所有者名下。
可以通过更改事件检测所有者更改。
为了解决这个问题,旧的聆听将需要被关闭,一个新的开放给新的业主。
  • 为了工作围绕这个旧的听将需要被关闭和一个新的 openea prim 不能听/听聊天它生成。不过,它可以听到新主人的连续声音。
如果在范围内,可以听到由 lldialog、 lltextbox 或链接 prim 间接生成的聊天。
示例
示例一
//  Says beep to owner the first time owner says something in main chat
//  and then stops listening
 
integer listenHandle;
 
remove_listen_handle()
{
    llListenRemove(listenHandle);
}
 
default
{
    state_entry()
    {
//      Change the channel number to a positive integer 
//      to listen for '/5 hello' style of chat.
 
//      target only the owner's chat on channel 0 (PUBLIC_CHANNEL)
        listenHandle = llListen(0, "", llGetOwner(), "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
//      we filtered to only listen on channel 0
//      to the owner's chat in the llListen call above
 
        llOwnerSay("beep");
 
//      stop listening until script is reset
        remove_listen_handle();
    }
 
    on_rez(integer start_param)
    {
        llResetScript();
    }
 
    changed(integer change)
    {
        if (change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
}

示例二

//  Opens two listen handles upon touch_start and
//  stops listening whenever something heard passes either filter
 
integer listenHandle_a;
integer listenHandle_b;
 
remove_listen_handles()
{
    llListenRemove(listenHandle_a);
    llListenRemove(listenHandle_b);
}
 
default
{
    touch_start(integer num_detected)
    {
        key    id   = llDetectedKey(0);
        string name = llDetectedName(0);
 
        listenHandle_a = llListen(5, "", id, "");
        listenHandle_b = llListen(6, "", NULL_KEY, "");
 
        llSay(0, "Listening now to '" + name + "' on channel 5.");
        llSay(0, "Listening now to anybody/anything on channel 6.");
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (channel == 5)
            llSay(0, name + " said: '/5 " + message + "'");
 
        if (channel == 6)
            llSay(0, name + " said: '/6 " + message + "'");
 
        remove_listen_handles();
    }
}
相关函数
llListenRemove--删除监听

llListenControl--允许/禁用一个监听 llWhisper--发送聊天限制在10米 llSay--发送聊天限制在20米 llShout--发送聊天限制在100米 llRegionSay--发送聊天限制当前 sim llRegionSayTo-- 发送聊天区域宽到一个特定的化身,或他们的附件,或一个已知 uuid 的 rezzed 对象

相关事件
listen