LlGetAnimation

来自人工智能助力教育知识百科
Kjf讨论 | 贡献2021年8月29日 (日) 02:39的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: string llGetAnimation( key id )
参数:key id–化身在同一区域的UUID
返回值:返回一个字符串,它是当前正在播放的化身id的运动动画的名称。见下表。
注意事项
注意事项
  • 这个函数可以在角色退出时返回一个空字符串。
  • 新的返回值可能会在任何时候被添加,而这个列表实际上可能并不完整。编写脚本时,应该假定它们可能接收到它们不认识的值。
示例
/ A simple animation override example.
// Make the avatar run in mid-air when jumping.
 
key gOwner; // the wearer's key
string gLastAnimation; // last llGetAnimation value seen
 
// User functions
 
Initialize(key id) {
    if (id == NULL_KEY) { // detaching
        llSetTimerEvent(0.0); // stop the timer
    }
    else { // attached, or reset while worn
        llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
        gOwner = id;
    }
}
 
 
// Event handlers
 
default
{
    state_entry() {
        // in case the script was reset while already attached
        if (llGetAttached() != 0) {
            Initialize(llGetOwner());
        }
    }
 
    attach(key id) {
        Initialize(id);
    }
 
    run_time_permissions(integer perm) {
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
            llSetTimerEvent(0.25); // start polling
        }
    }
 
    timer() {
        string newAnimation = llGetAnimation(gOwner);
 
        if (gLastAnimation != newAnimation) { // any change?
            if (newAnimation == "Jumping") {
 
                // You can stop the built-in animation if you like, if
                // it might interfere with your own. Be aware that an
                // avatar can become stuck, and some llGetAgentInfo results
                // can be inaccurate, if you stop built-ins indiscriminately.
                // Always test.
                //
                // llStopAnimation("jump");
 
                llStartAnimation("run");
            }
            else if (gLastAnimation == "Jumping")  { // just finished jumping
                // "run" is looped, so we have to stop it when we are done.
                llStopAnimation("run");
            }
 
            gLastAnimation = newAnimation; // store away for  next time
        }
    }
}
相关函数
llGetAgentInfo

llGetAnimationList

相关事件