: timer.ayaan — cooldown / interval helpers
:
: Each "timer" is identified by a string name. State lives in the dict
: __gt_timers so multiple timers can coexist.

dict __gt_timers

: Start (or restart) a named timer with N frames to count down.
func timer_start name frames
    dset __gt_timers name frames
endfunc

: Decrement a named timer by 1 (call once per frame).
func timer_tick name
    dget __gt_timers name -> t
    if t > 0
        set t = {t - 1}
    endif
    dset __gt_timers name t
endfunc

: Returns 1 if a named timer has reached 0 (i.e., expired).
func timer_done name
    dget __gt_timers name -> t
    set result = 0
    if t <= 0
        set result = 1
    endif
endfunc

: Returns the current remaining frame count for a timer.
func timer_remaining name
    dget __gt_timers name -> t
    set result = t
endfunc
