What's going wrong with my save system?

Ah thanks @vendetta didn’t spot that.

Will test it out now

edit: still isn’t working right. I think it may could be it seems to bypass the save screen then changes it back to default.

Will look into it further.

Hmm. Still using *finish in the earlier episodes? Once you incorporate a save system, that command actually becomes pretty redundant, otherwise it’s forever bypassing your save feature . . .

In place of *finish you’ll probably find that you need to *goto end_of_episode everywhere instead, as that’s where it actually sets your save_flag and then heads into savegame before redirecting to the next episode (in pretty much the same way as you use *goto dead where applicable to head to the restore function).

Edit: Yep, good possibility–I found two *finish commands in episode00 (Alpha & Beta paths). As it stands now, it looks (at a quick glance) like only the Gamma path would actually hit the save function.

Also spotted a typo in the *label gamma text while having a sneaky peek . . . erm, I mean while bug-hunting! *cough*

“You smile but you quickly shoots you down when she adds you have”

I believe that you should be ‘she’.

@Vendetta

I think that’s done it!

I can continue episode 2 now :slight_smile:

@Nocturnal_Stillness Excellent–your project has far too much potential to see it flounder in frustration.

@Vendetta

Thank you :slight_smile:

I have another solution for you if you are interested. This solution adds two additional CS commands, *save_checkpoint and *load_checkpoint. Here’s what you do.

First, create a file called checkpoint.js in the same directory as scene.js.

Edit the checkpoint.js file with your favorite file editor, enter the following code (make sure you get the upper and lower case letters exactly as shown below), and save the file:


Scene.password = null;
Scene.prototype.save_checkpoint = function() {
  Scene.password = computeCookie(stats.scene.stats, stats.scene.temps, stats.scene.lineNum, stats.scene.indent);
}
Scene.prototype.load_checkpoint = function() {
  var state = null;
  if (!Scene.password) {
    alert("Sorry, no checkpoint was created from which to restore your game.");
    return;
  }
  try {
    state = eval("state="+Scene.password);
  } catch (e) {
    alert("Sorry, there was a problem in restoring your game from the last checkpoint.");
    return;
  }
  saveCookie(function() {
    clearScreen(function() {
      restoreGame(state, null, true);
    })
  }, "", state.stats, state.temps, state.lineNum, state.indent);
}
Scene.validCommands.save_checkpoint = 1;
Scene.validCommands.load_checkpoint = 1;

Now go to your web directory and open index.html in your file editor. Look for the following line of code:


<script src="../navigator.js"></script>

Right below that line of code, enter the following line of code:


<script src="../checkpoint.js"></script>

You have now enabled *save_checkpoint and *load_checkpoint commands for your game. In each scene that you want to checkpoint, enter the *save_checkpoint command as the first non-*comment command in the file. At whatever point in your game you want to restore to the last saved checkpoint, use the *load_checkpoint command. I’ve tested it to some degree, and it has even worked across scenes for me, so that if my last saved checkpoint was in another scene than the one where I call *load_checkpoint, it indeed loads the scene where the last checkpoint was saved. It could use further testing, if anyone is interested in testing it.

Wherever you use the *load_checkpoint command, I would suggest following it up with text that basically says oops, and following that with an *ending command, in case the *load_checkpoint command fails to load a checkpoint for any reason. Hope this is of help.

@eposic
This sounds like something I would like to use. Once I have chapter one in better shape I will try to use this.

Seems to work great, does it save your variables states though?
Seems to, awesome.

Thanks for sharing that man :slight_smile:

Glad you like it, @CJW, and hope you will too, @Lordirish. Let me know if you see any problems with it.

@eposic
Thanks I will. I think I understand most of it and can follow direction some what, lol. I am sure I will break it in the process once or twice, but I don’t give up that easy.

Ok I have all the files in place. I added *save_checkpoint after they have picked all their NPC’s then put *load_checkpiont in at the start of chapter one. Now when I run the game the text flashes for a second for chapter one but will not let me go any further. I have placed the code later into the page but same results. Any idea what I am doing wrong.

Have you remembered to include the checkpoint.js file in index.html? And added both commands as valid?
`

`
2. Scene.validCommands.save_checkpoint = 1;
Scene.validCommands.load_checkpoint = 1;

??

Ok played with the placement. Placed the *save at the very start then placed *load into the first section after they picked their *NPC’s now it loops back to the very begining. Lol. Will put this part of the project on hold til I can get a little help with it.

*edit yes @CJW I did, when I upload my next update will give links so you can see where I may have screwed up thanks.

Yeah that’s what it does; it loads your *save state. So if you *save_checkpoint at the start, *load_checkpoint will restore your stats AND take you back to that same start scene.

Ok so if I put*save at the start of firstchapter part two it will save all the stats up to that point. Then *load at the end where I want to reload, correct. Lol I guess I got it working then lol.

*edit that’s two I owe you @CJW. :wink:

*edit2 this really rocks, hunting down bugs is going to far simpler. As I add new section can test over again quickly.

Eeyup, I just want something that isn’t session based now, a little sick of accidentally hitting the back button and having to start all over :frowning:

Lol I know the feeling

@eposic
Sweet plebian citizens!!!

You have already made a huge contribution with those extra commands there man. I can not tell you enough how much you have just helped me out and saved me hours of head ache trying to implement a flag save system.

-Matt

Glad to be of help, @mattnoles. I piggybacked off of the CS “password” system hiding in the official CS download.

@CJW, the official CS download has an import/export feature that allows you to export a “password” that you can then import to restore the game to the state it was in when you did the export. The export of a saved game is done with the *show_password command, which is turned on by default. The import of the saved game is done with the *restore_password command, which is not turned on by default, perhaps because it is perceived as a bit clunky. If you edit the scene.js file and add “restore_password” as a valid command at the bottom of the file (follow the examples of the other commands), you can test out the import/export feature and see if it works for your testing purposes. Call the *show_password command when you want to save your game, and save off the “password” it generates. Then call *restore_password when you want to restore the saved game, at which time you must paste in the “password” that was previously exported. You can save off several exported “passwords” in an external file, to reflect different save points in the game, and import the desired “password” to restore the game to the desired save point. It is imo too clunky to make available to players, but it should serve well enough for testing purposes.