diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-11-02 20:55:56 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-11-03 19:33:18 +0800 |
commit | 3f72f9a202bed628f838cc24fe58a0511ca0d161 (patch) | |
tree | 0684cfff91551d9b6aabdb825981b46a5cb53fe8 /indra/newview/scripts/lua/test_animation.lua | |
parent | d302bf3c96666cfd46d7585cb3d8b6ec27bb83bf (diff) | |
parent | 9c0a6d1b0e5e9d6da6a63ff367f40ab08c064bbe (diff) |
Merge remote-tracking branch 'secondlife/release/maint-c' into maint-c
Diffstat (limited to 'indra/newview/scripts/lua/test_animation.lua')
-rw-r--r-- | indra/newview/scripts/lua/test_animation.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/test_animation.lua b/indra/newview/scripts/lua/test_animation.lua new file mode 100644 index 0000000000..ae5eabe148 --- /dev/null +++ b/indra/newview/scripts/lua/test_animation.lua @@ -0,0 +1,32 @@ +LLInventory = require 'LLInventory' +LLAgent = require 'LLAgent' + +-- Get 'Animations' folder id (you can see all folder types via LLInventory.getFolderTypeNames()) +animations_id = LLInventory.getBasicFolderID('animatn') +-- Get animations from the 'Animation' folder (you can see all folder types via LLInventory.getAssetTypeNames()) +anims = LLInventory.collectDescendentsIf{folder_id=animations_id, type="animatn"}.items + +local anim_ids = {} +for _, key in pairs(anims) do + table.insert(anim_ids, {id = key.id, name = key.name}) +end + +if #anim_ids == 0 then + print("No animations found") +else + -- Start playing a random animation + math.randomseed(os.time()) + local random_anim = anim_ids[math.random(#anim_ids)] + local anim_info = LLAgent.getAnimationInfo(random_anim.id) + + print("Starting animation locally: " .. random_anim.name) + print("Loop: " .. tostring(anim_info.is_loop) .. " Joints: " .. anim_info.num_joints .. " Duration " .. tonumber(string.format("%.2f", anim_info.duration))) + LLAgent.playAnimation{item_id=random_anim.id} + + -- Stop animation after 3 sec if it's looped or longer than 3 sec + if anim_info.is_loop or anim_info.duration > 3 then + LL.sleep(3) + print("Stop animation.") + LLAgent.stopAnimation(random_anim.id) + end +end |