From df84287e6562481f3094959874ebbd5c63d4f826 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Mon, 18 May 2026 23:46:21 +0200 Subject: [PATCH] =?UTF-8?q?feat(puppet):=20v0.4.4=20=E2=80=94=20set=5Fplay?= =?UTF-8?q?=5Fspeed(handle,=20anim=5Fid,=20speed)=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- init.lua | 16 ++++++++++++++++ manifest.lib | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) 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": [] }