State Machine for Lua