-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Default script - does nothing. local idleFrames = {[1] = {from = 1, to = 251}, [2] = {from = 252, to = 351}, [3] = {from = 352, to = 652}, [4] = {from = 653, to = 713}} local danceFrames = {[1] = {from = 714, to = 1437}, [2] = {from = 1438, to = 2032}, [3] = {from = 2033, to = 2104}, [4] = {from = 2105, to = 2464}, [5] = {from = 2465, to = 3022}, [6] = {from = 3023, to = 3582}, [7] = {from = 3583, to = 4041}, [8] = {from = 4042, to = 4433}, [9] = {from = 4434, to = 5270}, [10] = {from = 5271, to = 5987}} g_music_playing = false local dancing = {} function dancer_init(e) local frames = idleFrames[math.random(#idleFrames)] dancing[e] = false SetAnimationFrames(frames.from, frames.to) LoopAnimation(e) end function dancer_main(e) if g_music_playing and not dancing[e] then local frames = danceFrames[math.random(#danceFrames)] StopAnimation(e) SetAnimationFrames(frames.from, frames.to) LoopAnimation(e) dancing[e] = true elseif not g_music_playing and dancing[e] then local frames = idleFrames[math.random(#idleFrames)] StopAnimation(e) SetAnimationFrames(frames.from, frames.to) LoopAnimation(e) dancing[e] = false end end