Guest User

Untitled

a guest
Jan 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. // Load story file
  2. string storyJson = File.ReadAllText ("Stories/musgraveritual.json");
  3. StoryModel model = StoryModel.Create (storyJson);
  4.  
  5. // Find the saved stitch and fast forward the story's initial stitch:
  6. string restoredStitchName = "holmesResumedHis"; // load this from disk
  7. foreach (var stitch in model.Story.Stitches) {
  8. if (stitch.Name == restoredStitchName) {
  9. // Fast forward the story to this stitch
  10. model.Story.InitialStitch = stitch;
  11. break;
  12. }
  13. }
  14.  
  15. // Load story into player
  16. StoryPlayer player = new StoryPlayer (model, new Inklewriter.MarkupConverters.ConsoleMarkupConverter ());
  17.  
  18. // Collect all saved flag strings
  19. List<string> restoredFlagStrings = new List<string> { "a:1", "b:2", "c:3" }; // load this from disk
  20. List<FlagValue> flags = new List<FlagValue>();
  21. foreach (var flag in restoredFlagStrings)
  22. {
  23. // TODO Convert flag strings into FlagValue objects. There's not a clean API for this,
  24. // but some code from StoryModel.ProcessFlagSettings could be recycled.
  25. }
  26.  
  27. // Create our first Chunk using the InitialStitch that we previously set,
  28. // and restore all of its saved flags.
  29. player.CreateFirstChunkWithFlags(flags);
Add Comment
Please, Sign In to add comment