Saving System Plugin


Save.js is deprecated, please see smPlugin.js instead.

For the more advanced (but more complicated) save-framework code, see this post
and download here: smPlugin.js

Or perhaps you’re looking for something that allows players to save ‘on the fly’ (like save.js) but with multiple slots? Try the smPluginMenuAddon.js

[spoiler]For as long as I’ve been here, saving games as been a huge problem and a save system has been on almost every developer’s wishlist.

I’m pleased to say, after a lot of thinking, a few epiphanies and some solid advice from @Vendetta - I’ve come up with a simple, and most importantly transferable solution!

What is it?
This is an automatic save system that acts like games hosted on the official CoG site (autosaves every page).

How does it work?
It uses the native password generating functions to create and store a password in your browser’s localStorage.
The load function then grabs this data and loads/processes a password page automatically in order to restore your game.
Whilst far from being the most glorious method, it seems to work well enough - and for testing purposes that’s all we really need.

The saving is automatic, but you can delete/clear your save and load via the included buttons:

How do I install it?
Because I thought this would be so useful to absolutely anyone creating a choicescript game on the forum I tried to make the inclusion of this mod as simple as is humanly possible (hence some of the limitations, like being single-slotted and automatic).

To install:

  • Download this file (right click and ‘save as’).
  • Put that file in your ‘webs’ folder (the one with ui.js and scene.js in it)

  • Open index.html and include the file as a script ( It MUST come after ui.js and scene.js):

  • Now all you need to do is open save.js and change the value of the variable at the top called “mygame_save”, to ensure your instance of the save system is unique to your game. Don’t keep changing this value however, as it’ll break your player’s saves.

How do I uninstall it?
Un-include the script file.

Things of Note

  • Only the latest versions of browsers support localStorage (IE8+) Chrome, Firefox etc.
  • This is only a one-slot save automatic save system, but it WILL retain information after you close your browser.
  • This mod overwrites some native interpreter functions so if you’ve made heavy edits to scene.js and ui.js - This mod may cause problems.

There’s a demo here if you have any doubts, simply load up the game play to a certain point - quit - load it back up and hit ‘load’ - you should return to exactly where you left off:

I’ve wanted to deliver this to y’all for a while now, and I’m really excited to finally be able to.
This system isn’t perfect, I know - but hopefully it’s a good start to fixing a common gripe and I hope it makes everyone’s cs deving that little bit easier, until something better comes along!

I hope it helps.

Merry Christmas EveryChoiceScripter! :)[/spoiler]

Save Game Feature
Save system like in tin star
New to COG-Do CS games automatically save progress between sessions?
[Resolved] How to do things like setting save points, making sure the game stays on the same part when you refresh a page?
Desparate noob question...
A Mortal Hero: Patron of the Gods (Demo updated 10/10)
((((OLD, NEW REMASTERED VERSION LINKED!)))) Keys (Fantasy WIP, Updated 9/5/18)
Black Flag: Lies Unhidden (WIP) - Demo Added
Children of the Gods (Important poll #12306)
Children of the Gods (Important poll #12306)
I need help in coding
For Her Majesty's Honor
Your playtesting methods?
Is it possible to add a "game progress saving" feature for my ChoiceScript game? If so, how?
Link/s to Save Plugins Help
N.O.A.H's Ark WiP (Ch2 Updated 12/2/2017)
Please help me with a plugin error!
Older development thread (The Aegis Saga - Blood)
Dashingdon: Free ChoiceScript Game Hosting
Smoky Skies - WIP (Updated 14-05-2017)
Creating a save game option within the code
Creating a save game option within the code
Enforcers of Magic : Hope [THREAD MOVED]
Checkpoint or savepoint / I was able to make some save slot lols!
Scratch (WIP)
Quite App-Parent: The Parenting Simulator. Year 15 Complete, and Now Actually Accessible! Updated 4/9/19
Journey to the throne(Wip) Updated 11 April
The Aegis Project (spy/thriller) (new demo 26-Dec)
Re: Saving option
Re: Saving option
So when coding a Choice Script Game how do you make a Save Load Delete section?

awsome!!! u rule



Thanks for this, I’ve added it to my game :slight_smile:


i think u should give credit to cjw for doing this for us i will put his name in my game

1 Like


Good point! I’ll add the credit!


Might want to redownload (or uncomment updateSave()), just realized I commented out the wrong function… -.-’
And don’t worry too much about the credit, it’s not like anyone should use this for a published game - it’s really only intended as temporary testing solution.


@CJW thanks will do.


Oh boy, this is awesome! :slight_smile:

1 Like

You always realize the oversights after you post something lol…

Although it’ll “work” without further configuration it will only work for ONE game, for e.g. if you play the demo and then play nocturnal_stillness’ unnatural - Unnatural will overwrite your demo save.

The developers of games can fix this by searching for all instances of “mygame_save” in save.js and replacing it with a unique id, like “unnatural_game”.

This is a really easy thing to do if you use the find and replace tool - Sorry about that - It’s something I didn’t consider during testing as I only had the one game.


@CJW thanks for the heads up!

and you have a credit in the game now (just choose Game information :slight_smile: )


@Nocturnal_Stillness Really don’t worry about it, a lot of the code is just reusing stuff already in the interpreter - and I know it’s not a suitable solution for publication, so I feel bad expecting credit for it.

It’s just a simple means to a simple end.

It is actually possible to do a bit more with it but it requires a hell of a lot of editing the core stuff (which would screw with games and be hard to tutorial). At a later date I plan to - possibly - take requests (from established games/authors) for more personalised instances with named save slots and options to make it non-automatic etc.

You’ll see something similar in the next update of Terminal.


CJW, you’re pretty amazing.

I do not have a game in progress, so I will most likely not use this. Maybe ever. But. I just felt the need to say that.


Awesome …it’ll come in handy…thanks :slight_smile:

1 Like

Yet again, you’ve done a great service to the community. I know that lengthier games will benefit a lot during testing because of this. You have my thanks. ^:)^

1 Like


just to let you know, your hard save system stops the following commands from working.

*show_password and *restore_game


That’s true, the save system overwrites some core functions, those being two of them.
I can try to ammend that, but it could make installation more tricky.



What I might do is ask in my topic whether people prefer to use passwords or the hard save version. Then drop which ever one is the least popular.


@Nocturnal_Stillness - What are the exact symptoms? It is possible to get them working together, it just might require edits to the core files (which for ease of installation and game breaking, I’m trying to avoid).


Well if you try to click the restore via password button it doesn’t work. the screen just flashes and thats it.

Try it in unnatural start a new game then click continue game and restore via password and you’ll see what I mean.


Ah, I see :open_mouth: - I’ll get straight on that!