So! I want to make my game save between sessions, and I’ve changed the window.storeName
in the index.html
as specified here: Saving between sessions. However! There appears to be a major issue - if you play the compiled game and refresh, then the next chapter is dropped, and when you reach the chapter transition it tells you to play again/share a game/whatever.
I tracked this down to the SceneNavigator
class, which is initialized via parsing the startup
file on new games and via mygame.js
in cases of refresh. In mygame.js
it’s coded as follows by default:
nav = new SceneNavigator(["startup"]);
stats = {};
So, as far as I can understand, it gets the full list on new game start. However if you refresh the page it only gets “startup”, so it runs fine right up until it needs to determine the next scene, then in Scene.prototype.finish
it throws its hands up and says that there’s no next scene and you must be done.
Now, I was given to understand by the wiki (Mygame.js | ChoiceScript Wiki | Fandom) that if I’m using the *scene_list command in the startup file, I shouldn’t have to mess with mygame.js
, but it looks like I actually should be mirroring my scene order in the JS file, since on refresh never actually goes back and parses out the *scene_list command. I tested this out by editing mygame.js
to add my chapters and it appears to have fixed the issue.
So I have two questions.
First, is that all roughly correct?
Second, is there anything else I need to do to make saves work properly? Right now, it’s:
1) change window.storeName to a unique value
2) edit mygame.js to add my scenes to the SceneNavigator