I'm a big fan of state machines in reactive designs. So when I started learning Lua it was among the first design patterns I started implementing.
You can find version 1 of an HSM pattern in Lua here: http://www.bellfelljar.org/trac/wiki/Lua%20Projects.
The design is based on the excellent work of Miro Samek (hence the module name "miros"). This implementation closely follows an older C/C++ implementation which I've also used. It was published in the 8/00 edition of "Embedded Systems" magazine by Miro Samek and Paul Montgomery under the title "State Oriented Programming". The article and code can be found here: http://www.embedded.com/2000/0008.
This module is pure Lua. I've learned alot doing it but I'm counting on you guys for suggestions to correct and improve it.
There's also an updated version of Lunar there that builds with recent MSVC releases and Lua 5.1.