TacticalMetaphysics / LiSE

Rules-based engine for life sims, with time travel
GNU Affero General Public License v3.0
116 stars 9 forks source link

Simple dialog system #43

Closed clayote closed 6 years ago

clayote commented 7 years ago

While it's possible to build your own dialog interface using Kv, some developers want to get straight to writing the actual dialog and don't need precise control over its appearance, or want to go to the effort of designing it. For them, LiSE should offer a way to display messages and choices in deliberate sequence using nothing more complex than function calls.

Sometimes this needs to happen in the middle of rule execution, which means that process needs to be able to stop early and still sync with the UI.

clayote commented 7 years ago

When an action's been executed it can currently return whatever it wants and I don't really do anything with it.

Instead, let's have it so when an action returns something, evaluation of the rule ends (so if it has other actions after that, they don't happen), the return value gets put into the universal dictionary, and the rule poller stops wherever it is. That means ELiDE will get a diff describing changes to the world so far this tick, but it no longer represents the state of the world next tick. I'll need to change the diff format a little, so that it indicates the change in the time.

ELiDE then calls a new method on the screen object, passing the value returned from the action into it. Perhaps it's just a string, in which case show the player a dialog box with that text in it. If it's a dictionary, interpret the keys as the option to show the player and the values as what to do in response -- partials, basically. If it's a partial, just call it. If it's a list, it should contain strings and dictionaries that will be evaluated one after the next, as stated, and pausing to let the player click on them in between. Except the partials. Just call those.

Anyway, when that method finishes execution, ELiDE calls next_tick again, possibly getting another action return, and repeat until the tick has been incremented and it's time to give the player control again.

clayote commented 7 years ago

I don't think I'll involve the universal dictionary in this. I can just change the next_tick function's return value to include whatever the last action returned, along with its description of changes to the world state.

clayote commented 7 years ago

Actually I will involve the universal dictionary as a place to keep the state of the UI in case the player quits while a dialog is open. Look in the universal dictionary for what to show upon next startup.

clayote commented 6 years ago

It's really basic, but this is in fact in Alpha 8