Minimalistic Lua implementation of a finite state machine.