diff --git a/init.lua b/init.lua index 19c618b..bd5da77 100644 --- a/init.lua +++ b/init.lua @@ -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 -- ==================================================================== diff --git a/manifest.lib b/manifest.lib index bc42043..f8a8cc6 100644 --- a/manifest.lib +++ b/manifest.lib @@ -1,6 +1,6 @@ { "id": "lib-core.puppet", - "version": "0.4.3", + "version": "0.4.4", "api_min": "0.1", "deps": [] }