LlAvatarOnSitTarget

来自人工智能助力教育知识百科
Wzc讨论 | 贡献2020年5月18日 (一) 10:19的版本 (创建页面,内容为“{{LSL Header|ml=*}}{{LSLC|Keywords}}{{LSLC|Flow Control}}{{LSLC|}} {{函数详情 |函数名=Function: key llAvatarOnSitTarget( ); |参数=返回一个密钥,…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: key llAvatarOnSitTarget( );
返回一个密钥,该密钥是位于prim上的用户的UUID。
如果prim缺少一个sit目标或者没有化身坐在prim上,则返回空密钥。
注意事项
prim没有sit目标,除非使用非零向量作为第一个参数调用llSitTarget

如果prim缺少一个sit目标,或者avatar位于另一个prim上,则确定对象上有多少个avatar以及哪些avatar的唯一方法是扫描链接集(例如,请参见llGetNumberOfPrims)。

示例
default
{
    state_entry()
    {
        // set sit target, otherwise this will not work 
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
    }
 
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        { 
            key av = llAvatarOnSitTarget();
            if (av) // evaluated as true if key is valid and not NULL_KEY
            {
                llSay(0, "Hello " + llKey2Name(av) + ", thank you for sitting down");
            }
        }
    }
}

有用的片段

/Gets the link number of a seated avatar
integer GetAgentLinkNumber(key avatar)
{
    integer link_num = llGetNumberOfPrims();
    while (link_num > 1) // Check only child prims.
    {
        if (llGetLinkKey(link_num) == avatar) // If it is the avatar we want
        {
            return link_num; // then return the link number
        }
        --link_num; // else go on with next child.
    }
    // Avatar wasn't found
    return FALSE; // 0 (zero) for easy testing.
}
//It's sometimes useful to use a state change
//useful when the prim is linked to an other prim
//and useful with a dialog box
default
{
    state_entry()  
    {
        //"Sit target is a prim property."
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
    }
 
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        { 
            key av_sit = llAvatarOnSitTarget();
            if (av_sit) 
            {
                //Someone is on the sit target.
                state sitting;
            }
        }
    }
}
 
state sitting
{
    state_entry()
    {
        //Open a dialog box when an avatar is sitting on the prim
        key av_menu = llAvatarOnSitTarget();
        llListen(-99, "", av_menu, "Yes");
        llDialog(av_menu, "\nDo you like this example?", ["Yes", "No" ] , -99);
    }
 
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        { 
            key av_unsit = llAvatarOnSitTarget();
            if (av_unsit == NULL_KEY) 
            {
                //No one is on the sit target.
                //"On state change all listens are removed automatically."
                state default;
            }
        }
    }
 
    listen(integer chan, string name, key id, string msg)
    {
        // If the user clicked the "Yes" button
        llWhisper(0, "Thank you");
    }
}
相关函数
llAvatarOnLinkSitTarget

llSitTarget

llLinkSitTarget

llGetLinkKey

文献 CHANGED_LINK

相关事件
The position of an avatar on a sit target can be determined with the use of llGetObjectDetails (see llSitTarget for an example).