animations
The animations namespace manages stateful numeric transitions keyed by unique identifiers. Values persist across frames without manual state tracking.
Functions & Methods
Section titled “Functions & Methods”animations.new
Section titled “animations.new”local anim = animations.new(name: string, start_value?: number) --> animation_tRetrieves or creates a named animation instance.
animation:update
Section titled “animation:update”local current_val = anim:update(type: number, target: number, speed?: number, min?: number) --> numberUpdates and returns the new value towards target.
type: Interpolation curve type fromanimations.types.*.speed: Transition speed coefficient (defaults to0.095, automatically scaled by frametime).min: Arrival epsilon threshold (defaults to1.0).
animation:get & animation:set
Section titled “animation:get & animation:set”local val = anim:get() --> numberanim:set(value: number) --> nilanimations.reset
Section titled “animations.reset”animations.reset()Clears all stored animation states in memory.
Animation Curve Types (animations.types)
Section titled “Animation Curve Types (animations.types)”animations.types.LERPanimations.types.SINE3animations.types.IN_SINE,OUT_SINE,IN_OUT_SINEanimations.types.IN_CUBIC,OUT_CUBIC,IN_OUT_CUBICanimations.types.IN_QUINT,OUT_QUINT,IN_OUT_QUINTanimations.types.IN_CIRC,OUT_CIRC,IN_OUT_CIRC
Example: Scope Crosshair Animation
Section titled “Example: Scope Crosshair Animation”client.add_callback("render", function() local me = entity.get_local_player() if not me then return end
local center = render.screen_size() / 2 local target_offset = me.m_bIsScoped and 40 or 0
-- Create and update persistent animation named 'scope_offset' local anim_offset = animations.new("scope_offset", 0) :update(animations.types.OUT_CUBIC, target_offset, 0.15)
render.text(2, vector(center.x + anim_offset, center.y), color(255, 255, 255), "c", "INDICATOR")end)