From aa6ac5f5bd024fc21d7550f3c1caed10980de439 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 10 Sep 2026 00:14:15 +0300 Subject: [PATCH] add animation.stop --- res/modules/animation.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index c42b15d25..fb0a915f2 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -68,13 +68,26 @@ end local running_actions = {} local playing_tracks = {} +local next_track_id = 1 function this.action(func) table.insert(running_actions, coroutine.create(func)) end function this.play(name, target) - table.insert(playing_tracks, {name=name, target=target, timer=0.0}) + local id = next_track_id + table.insert(playing_tracks, {id=id, name=name, target=target, timer=0.0}) + next_track_id = id + 1 + return id +end + +function this.stop(id) + for i, entry in pairs(playing_tracks) do + if entry.id == id then + table.remove(playing_tracks, i) + return + end + end end function internals.on_animation_frame()