4 ms·
For simple dialogs that don't have to be saved (see the other discussions), this seems like an easy way to quickly put any format of dialog system together with
by dividuum 10y ago
For simple dialogs that don't have to be saved (see the other discussions), this seems like an easy way to quickly put any format of dialog system together without reinventing your own DSL to encode those dialogs as state machine(s). You can easily compose dialogs just by calling functions and thanks to Luas tail call optimization you could even jump between dialogs without the fear of running out of stack space.
I'm not saying it's the best solution but it's pretty simple and probably easy to understand. I've used a similar approach way back in a networked multiplayer game where players could telnet into the game server and use text based menus to control the game. You can see the relevant Lua code here: https://github.com/dividuum/infon/blob/master/server.lua https://github.com/dividuum/infon/blob/master/server.lua. I don't want to imagine how this code would look like without the use of coroutines.