ChoiceScript Save Plugin 2019
Hi all, I spent this weekend completely revamping the current state of the save plugins.
For those new to this, or simply eager to get saves up and running, you can jump straight in by following the link below:
For those who’ve been around a while, or are interested in some history (and/or technical details), please read on. As many people have been saying for a while now, the save plugin situation had become something of a nightmare. With multiple scripts, broken links and scattered (and lacking) documentation all playing a big part. It was proving very difficult for old and new members alike to trundle through this thread finding out which links worked, which files they needed, and how to then use the various features of each script.
I’ve spent the weekend completely tearing apart the two “current” scripts: smPlugin.js and smPluginMenuAddon.js, and combining the majority of their behaviour into one script: ChoiceScriptSavePlugin.js.
I also rewrote the vast majority of the code, making it more reliant on CoG’s own save system (which amusingly Dan also flagged up this weekend). The benefits are still the same though. Unlike just simply enabling the above persistent storage, the plugin allows for you (or the player) to manage a number of save “slots” and provides both new commands and a “quick save menu” through which to do it.
But to cut a long story short: The end result should be something a lot more stable, intuitive and easier to maintain. I’ve also completely re-wrote a detailed configuration and usage guide (with pictures!), which you can view at the link above.
This is now the ‘default’ recommendation, and I won’t actively support save.js, smPlugin.js or smPluginMenuAddon.js (even just typing that out makes me realize how bloated and confusing that must have been!) from here on out.
I hope these changes prove helpful and for the better, but please let me know if you can think of any further improvements.
Old Post (pre:sept 2019)
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
[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).
- 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]