Saving System Plugin


#1

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

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:

https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/autosave-plugin/index.html


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! :)


Save Game Feature
Checkpoint or savepoint / I was able to make some save slot lols!
[Resolved] How to do things like setting save points, making sure the game stays on the same part when you refresh a page?
New to COG-Do CS games automatically save progress between sessions?
Save system like in tin star
Children of the Gods (Important poll #12306)
Creating a save game option within the code
N.O.A.H's Ark WiP (Ch2 Updated 12/2/2017)
Older development thread (The Aegis Saga - Blood)
Creating a save game option within the code
Enforcers of Magic : Hope [WIP] [Updated-6/26]
Dashingdon: Free ChoiceScript Game Hosting
Link/s to Save Plugins Help
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?
I need help in coding
Black Flag: Lies Unhidden (WIP) - Demo Added
Smoky Skies - WIP (Updated 14-05-2017)
Through Broken Lenses (Update 36 on 5 FEB 2018) WiP
Children of the Gods (Important poll #12306)
#2

awsome!!!!! u rule


#3

@CJW

Thanks for this, I've added it to my game smile


#4

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


#5

@irule9344

Good point! I'll add the credit!


#6

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.


#7

@CJW thanks will do.


#8

Oh boy, this is awesome! smile


#9

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.


#10

@CJW thanks for the heads up!

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


#11

@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.


#12

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.


#13

Awesome ...it'll come in handy..thanks smile


#14

@CJW
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. ^:)^


#15

@CJW

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

*show_password and *restore_game


#16

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.


#17

@CJW

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.


#18

@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).


#19

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.


#20

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