I stitched together rings (for multiple states) and pluto (for data serialization) some time ago. Rings is not intended for preemptive multitasking, but you can probably adapt to luathreads or something else with few adaptations: http://lua-users.org/lists/lua-l/2007-12/msg00440.html