3 ms·
One big problem with using coroutines for "scripting" long running events in games I don't often see mentioned is what to do - if anything - about saving their
by jamesu 11y ago
One big problem with using coroutines for "scripting" long running events in games I don't often see mentioned is what to do - if anything - about saving their state. For cutscenes this can be ignored for sure, but what if you tie something like a long conversation tree into a coroutine?
For this example library if your making some sort of traditional adventure game and you wanted the player to be able to save the game you'd have to restrict saving to checkpoints, use a loop with a switch (practically moving back to the state machine approach), or just split the conversation up into multiple coroutines as it progresses.
And of course, there's the whole "what to do when you need to patch the game" problem on top of all that.
- arianvanp 11y agoThere was a discussion in the /r/haskell subreddit about serialisable coroutines a week back: https://www.reddit.com/r/haskell/comments/4a8wr8/how_to_get_serializable_coroutines/ https://www.reddit.com/r/haskell/comments/4a8wr8/how_to_get_... Perhaps it helps
- TillE 11y agoYeah, I've had the exact same problem while exploring coroutines. Stackless Python is the only implementation I'm aware of which allows you to trivially serialize its microthreads. In the end, I prefer to just use mostly "stateless" Lua scripts, with all the saveable data managed in C++.
- vmorgulis 11y ago> For cutscenes this can be ignored for sure, but what if you tie something like a long conversation tree into a coroutine? I would use an embeddable scripting language (like Duktape) for entities. The state would be available at any time. It can also be parallelized. http://duktape.org/ http://duktape.org/
- looki 11y agoAs a lot of people have mentioned Lua ITT, there's a library called Pluto[1] which can serialize coroutine states. It was used in the game Fable to store quest statuses[2]. [1]: http://lua-users.org/wiki/PlutoLibrary http://lua-users.org/wiki/PlutoLibrary see also Tamed Pluto [2]: http://www.slideshare.net/hughreynolds/lua-and-fable-jonathan-shaw-lionhead http://www.slideshare.net/hughreynolds/lua-and-fable-jonatha...