Story.run()

This commit is contained in:
2024-04-13 15:24:47 -06:00
parent 2f5d4cebfa
commit 7b5e58ae68

View File

@@ -661,4 +661,25 @@ class Story {
// If no special hook is defined for the value to insert,
return Std.string(value);
}
public function run(
showText:(String,Void->Void)->Void,
showChoices:(Array<String>,Int->Void)->Void,
finish:Void->Void)
{
var loop = run.bind(showText, showChoices, finish);
switch (nextFrame()) {
case HasText(text):
showText(text, () -> {
loop();
});
case HasChoices(choices):
showChoices(choices, (choiceIndex) -> {
choose(choiceIndex);
loop();
});
case Finished:
finish();
}
}
}