tw.animation
Side: Client
Animation dictionary loading and playback utilities.
Constants
| Constant | Value | Description |
|---|---|---|
tw.animation.easeIn | 4.0 | Ease-in blend speed |
tw.animation.easeOut | -4.0 | Ease-out blend speed |
Functions
tw.animation.load(dict, waiter?)
Loads an animation dictionary into memory.
| Parameter | Type | Default | Description |
|---|---|---|---|
dict | string | — | Animation dictionary name |
waiter | boolean? | false | If true, blocks until the dictionary is fully loaded |
tw.animation.play(ped, dict, name, duration?, flag?, offset?)
Plays an animation on a ped. Automatically loads the dictionary if not already loaded.
| Parameter | Type | Default | Description |
|---|---|---|---|
ped | integer | — | Ped entity handle |
dict | string | — | Animation dictionary name |
name | string | — | Animation clip name |
duration | integer? | -1 | Duration in ms (-1 = full animation length) |
flag | integer? | 0 | Animation flags |
offset | number? | 0.0 | Start offset (0.0 to 1.0) |
Returns: number — Duration of the animation in milliseconds.
Examples
Play an animation
lua
local ped = PlayerPedId()
local duration = tw.animation.play(ped, "amb_work@world_human_sweeping@base", "base", 5000)
Wait(duration)
ClearPedTasks(ped)Pre-load a dictionary
lua
-- Load in advance (blocking)
tw.animation.load("mini_games@story@beechers@john_quests@finger_filet@table_a", true)
-- Play later without loading delay
tw.animation.play(ped, "mini_games@story@beechers@john_quests@finger_filet@table_a", "round_1_idle", -1, 1)Using ease constants with flags
lua
-- Play with looping flag (flag 1)
tw.animation.play(ped, "amb_work@world_human_sweeping@base", "base", -1, 1)Notes
play()auto-loads the dictionary, so you do not need to callload()first unless you want to pre-cache.- When
durationis-1, the animation plays for its full natural length. - Common flags:
0= normal,1= looping,32= upper body only,48= upper body looping.

