Save.js is deprecated, please see smPlugin.js instead.
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
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).
- 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! :)