Here is a snippet from the "carl" script in my LEM demo:
if g_ml_cutscene_complete and g_carl_mode == 0 and
CloserThan(500, g_Entity[e]) then
SetAnimationFrame(e, 3000)
StopAnimation(e)
g_carl_timer = g_Time + 2000
g_carl_mode = 1
return
end
if g_carl_mode == 1 and g_Time > g_carl_timer then
DisplayText(g_Game_Messages["carl1"], {x = 30, y = 5}, 34)
g_carl_mission = true
g_carl_mode = 2
SetAnimationFrames(3550, 3680)
PlayAnimation(e)
g_carl_timer = g_Time + 3000
end
if g_carl_mode == 2 and g_Time > g_carl_timer then
StopAnimation(e)
SetAnimationFrames(4610, 4676)
PlayAnimation(e)
g_carl_mode = 3
g_carl_timer = g_Time + 4000
end
Obviously there is a lot more of it but you should get the idea.
Been there, done that, got all the T-Shirts!