feat(puppet): v0.4.4 — set_play_speed(handle, anim_id, speed) API

New public function to change the play-speed of a currently-playing
animation WITHOUT resetting its cycle position. Calling M.play with a
new speed sets t=0, causing visible cycle restart; set_play_speed
mutates only the speed field.

Use case: sprint toggle mid-walk doubles walk-anim cadence smoothly.
Silent no-op when the anim is not currently playing.
This commit is contained in:
Axel Meyer
2026-05-18 23:46:21 +02:00
parent f7fa24965b
commit df84287e65
2 changed files with 17 additions and 1 deletions

View File

@@ -522,6 +522,22 @@ function M.is_playing(handle, anim_id)
return all_puppets[handle].playing[anim_id] ~= nil
end
-- v0.4.4: Change the play-speed of a currently-playing anim WITHOUT
-- resetting its cycle position. Silent no-op if anim is not playing.
-- Use case: sprint toggle mid-walk doubles anim cadence without
-- visible cycle-restart (which calling M.play again would cause).
function M.set_play_speed(handle, anim_id, speed)
local p = all_puppets[handle]
if p == nil then
error("puppet.set_play_speed: handle " .. tostring(handle) .. " not spawned")
end
local play_state = p.playing[anim_id]
if play_state == nil then
return -- silent no-op
end
play_state.speed = speed
end
-- ====================================================================
-- Look-at + bone queries
-- ====================================================================

View File

@@ -1,6 +1,6 @@
{
"id": "lib-core.puppet",
"version": "0.4.3",
"version": "0.4.4",
"api_min": "0.1",
"deps": []
}