Using Lua coroutines to create an RPG dialogue system
I&#x27;ve done this kind of thing in Lua before, but what troubles me about it is the fact that a lot of the state of your game ends up encoded in the Lua stack.<p>What happens when the user wants to save? There&#x27;s Pluto [1], which is somewhat slow for complex state. And it doesn&#x27;t work on LuaJIT code -- and I tend to like to run games on LuaJIT.<p>And it&#x27;s opaque: If you&#x27;re debugging some kind of interaction in the game, you can&#x27;t just look at the save state to see what&#x27;s where.<p>I used to be a big fan of Lua, and this kind of AI and behavior coding was a component of that. But ... I think that, on balance, actually creating a data format that represents the state and &quot;coding&quot; using that plus state machines is actually a more robust and useful way to accomplish the same thing.<p>[1] <a href="http:&#x2F;&#x2F;lua-users.org&#x2F;wiki&#x2F;PlutoLibrary" rel="nofollow">http:&#x2F;&#x2F;lua-users.org&#x2F;wiki&#x2F;PlutoLibrary</a>