A guide to temporary save states for WIPs

This question gets asked pretty often, and I don’t think it has its own topic yet. So, here’s how you add checkpoints/save states to a WIP, so testers can have this function before COG adds their official version at publication.

  1. Make a scene. I called mine save_states. Find every variable that could possibly change over the course of the game, and make two lists of them. One will be used for saving, one for loading.
  2. Go to startup. *create a saved_variable for every variable (e.g. if a variable is strength, create saved_strength.) Keep all of these together so you can delete them when they’re no longer needed (when you’re stripping the temporary save states back out before COG adds the official system.)
  3. Under a label save_these_stats, paste a set command in front of each variable. Then add the matching saved_variable to each line. It will look like: *set saved_strength strength
  4. Under a label load_these_stats, do the same thing but in the reverse order. Like so: *set strength saved_strength
  5. You can use gosub_scene to save, so add a *return at the end of save_these_stats. The full command to get there would be: gosub_scene save_states save_these_stats
  6. Using a gosub rather than a goto for loading can mess up your options; any options that were greyed out after being chosen will still be unavailable, if you’re reloading within the same scene. So instead, set a variable called checkpoint. Name each checkpoint.
  7. Use goto load_these_stats to load, then depending on the name of the checkpoint, use a goto to send the player to the right scene and label.

Tada. It’s time-consuming to set up at first, and you have to remember to keep updating it as you add more variables. But it’s pretty easy once you get the hang of it.

WARNING: This method only works if the player doesn’t close their browser, turn off their computer, or clear their cookies. It’s still helpful to testers, but there’s no such thing as a reliable, truly permanent variable in a WIP.


A question from the original thread this cropped up in:

Passwords are used to unlock “New Game+” content (if you want to give the player more options after completing the game once, getting a certain ending, etc.) You give them a code at the end (sometimes randomly generated but I don’t really see the point, I’d use the same one for each achievement.) They can then enter in-game to set new_game_plus true and display those options/scenes/whatever.

I suppose you could also use a password to reload from a certain checkpoint, but if you’re writing in a choice of which one to go back to, a list of options would be an easier and better-looking solution. In theory a password would avoid the problem with closing your browser/refreshing cookies (which will clear the game’s memory and prevent this from working.) But unless you have some external place you’re using to save their information as of that point in the game, there’s no way to permanently store those variables as the player had them. So it would only work if each new chapter somehow starts the player off with no stats, no inventory, no existing relationships.

Choice of Games has a much more elegant system that they implement when the game is published. This is a workaround for use during testing, and it’s really not that bad once you get the hang of it. Time-consuming, like I said, but not complicated to use.

An alternative and perhaps less time-consuming method is the *show_password one:

You have just started Chapter 2.  Do you want to restore a game?
    *goto regular_start
    *goto regular_start
*label regular_start


Chapter 2: The Shugenja

What show_password does is display a large string you can copy, and later paste into the restore_password textbox. If you do this at the start of each chapter, players will be able to go back and make different choices etc. As long as players have those large strings of text saved somewhere, they can exit their browser and still get back to where they were with the same stats.

Forgot about this, but you’ll have to open up the index.html file (with notepad++ for example) in your mygame folder and look for:

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

Beneath that, insert this:

Scene.validCommands["restore_password"] = 1;

This will allow you to use the restore_password command.


So this system is currently working, and can be used to save all variables at various checkpoints? If that’s confirmed, it has some advantages over what I described in the first post.

Note to self: Attempt to implement password system into story later today.

I don’t think it works anymore. But it used to be how CoG games saved, you got a password it wasn’t tied to an online account like it is now.


*restore_password is a ‘non-existent command’ …unfortunately.

It doesn’t work. :frowning:

Updated my post; see if that fixes it.

You have to exit from the browser for the change to work, but it does work. After restarting, it will bring an input password screen! It still only works if you have not closed your browser- inputting it if you have does nothing. But if you have it takes you to the place where you *show_password, picking up as if you’re continuing from that point. Note, you do have to remove the -begin password- and -end password- before submitting.

@MultipleChoice It did fix the problem. Thank you.

@Sashira The password system works; which takes a bit less work than the method you mentioned, but please note I’m using a computer- which allows me to copy/paste the password into word. On a smartphone or tablet, this might not work, and so your method might be valid for those devices.

1 Like

Given that it requires an edit of something other than a scene file, is the restore password function still allowed in Choice of Games games?

  1. I’m not talking about using it to save games (appreciate there is a mechanism for doing that in published games) but to transfer externally generated information.

  2. Also I appreciate Hosted Games allows mods. I’m just asking about the CoG label.

And now we don’t edit index.html, how is this done?

Lastly, is there a way to interpret parts of a variable:
Simple example:
input_name Joe Blogs
Interpreted by your code and *set ing two other variables automatically, like *set firstname “Joe” and *set secondname “Blogs”

Now imagine this applied to numbers
So *input_number 1234
Interpreted by your code, leading to
*set firstpair 12
*set secondpair 34

. . . Maybe this last is off topic. I’ll make a new thread