Story.run()
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user