ChoiceScript Saving Plugin (Update: Sept. 2019)

thnx for all this @CJW its a perfect christmas present :wink:

1 Like

Now it works, thanks!

Glad to hear it, thanks for the headsup. I’ll try to work in a more intuitive error message for future iDevice users! :slight_smile:

1 Like

you are awesome

is the new name your save thing out yet?


“Unnatural” is being the Guinea pig for the new save system.

@akatsuki9344 Thank you - I’m just glad I can help! :slight_smile:

If you’ve yet to encounter any problems I’ll get working on the compatibility, ready for public use.

@CJW no issues yet and no complaints either. The save system and yourself both ROCK :slight_smile:

yeah i tried it on unnatural it works fine

There’s an IE9 bug (IE8 seems to work fine believe it or not) that results in the following error:

Everytime you try to do a ‘shown’ save.
I’m trying to work on a solution but it’s difficult seeing as the problem might be in the alertify.js library, not my own code.

Might have to revert back to standard js prompt boxes.

so when is the new type of save system coming?

Wow, I’m glad this was bumped as I hadn’t seen it. I guess it’s on the wiki too and I missed it? Should be stickied for certain.

Typical that IE9 has issues with it, however, I think I’ll try implementing this once I’ve reached the end of the chapter on my wip.

@CJW - thanks for this, where would COG be without all of your helpful hacks/fixes/tips?

@akatsuki9344 It shouldn’t be too long now, all the functionality is there, I just want to ensure it catches incompatible browser configurations and problems without crashing the game.

@bawpie I’m really glad you like it! But it isn’t on the wiki just yet, and only the basic version is available to download.

@CJW - read the whole thread after posting (d’oh) so I see a more advanced version is in the works. I’ll stick with what I have for now, but will certainly implement the flashier version when it’s out!


You can see the flashier version in my game I’m @CJW s guinea pig for it lol

@Nocturnal_Stillness - that’s really nice, can’t wait for it to be released. Btw, you might want to update your game link on the wiki as it’s broken :slight_smile:

1 Like

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

Release - smPlugin.js

The new ‘framework’ save system is done.

I don’t currently have the time or willpower to write up proper documentation for it.

There’s a demo here, which should be enough to grasp the general concept:

Demo Code

Instructions and Basic Info in a Nutshell

  • Uses browser localStorage to store/restore generated between browser sessions on the same computer/device. Older browsers, some mobile browsers etc do not support localStorage.

  • If a browser doesn’t support localStorage the system shouldn’t stop your game from working, it’ll only inform the player they can’t save - not actually “crash” - let me know if it does.


Must be used before any other sm commands, right at the top of your first scene file is ideal. This initializes the system, checks for previous saves etc.

It takes two arguments, the name of your game and the number of save slots.
Try to choose these two values carefully when you first implement this system and stick with them. Changing the game name will result in loss of your player’s saves.

*sm_init mygame | 5

Does exactly what it says on the tin. Saves the game (if it can).
This one takes three arguments, the first two are compulsory and the last one is optional.

The first one is the slot number the game should save to, it HAS to be a “number” and it has to be a WHOLE number - it also has to be between 0 and your number of slots (as declared with sm_init).

*sm_save 3

The second argument on sm_save is the type of save, there’s two:

Hidden Saves & Shown Saves

Hidden saves will just save like that without any input from the player, nor any notification that a save has taken place.

Shown saves will prompt the player to save (but he can decline), it’ll also allow them to rename a save, if they so wish.

Shown Save to slot 3
*sm_save 3 | true

Hidden Save to slot 3
*sm_save 3 | false

The last argument is optional (the above code examples will work) and is the save name. For both shown and hidden saves you can provide a ‘default’ name for a save - this is particularly useful for hidden saves, where the player cannot rename them themselves.

For example we’re coding our game and come to the end of a chapter - we don’t want to ruin the experience with a big ugly ‘please save’ popup, so we’ll do a hidden save. However, we want the player to know (when loading) exactly where he is - he won’t remember ‘saving’ this one after all.

Hidden Save to slot 2 with a default name
*sm_save 2 | false | End of Chapter 5 - Close Call

Now when the player tries to load a save, this one will appear with that name.
If you don’t provide a default name a time and date will be used instead.

Much like sm_save, sm_load does exactly what you think it does; loads saves.

It takes the same two compulsory arguments as sm_save, the slot number from which it should be loading and the hidden/shown parameter.

Force load a game from slot 3
*sm_load 3 | false

Prompt the player to load a game from slot 3
*sm_load 2 | true

Takes one argument, the slot number.

*sm_delete 1
*sm_delete 2


Again it has to be within the bounds of your defined number of slots, so watch that.
Deletion will ALWAYS prompt the player you can’t silently delete saves, yet. I might add it in if there’s popular demand.

Note on Slots

THINK! This is a do-it-yourself framework, not a automatic system like the save.js - There are many ways and means by which you can use these commands. Experiment a little, find what works for you.

If you’re going to mix manual and ‘automatic’ saving, keep the slots separate. Players won’t be happy if you’re constantly overwriting their manual saves with automatic ones.

Say slot 0 is the automatic slot, don’t allow manual saves to slot 0. Simples.

Have fun, report bugs, make cool games etc etc ^^’

Oh yeah… The system uses the typical js notifcation boxes, not alertify.js’ because IE kept throwing a tantrum and I’d personally rather have the functionality over the aesthetic appeal.


finally you rock !!! thanks very much

@CJW, you are incredible. Thank you for all the work you put into the save system.

1 Like

Fantastic job, @CJW. Thanks, especially, for making it so flexible. I’ve been tinkering with the system for a little while and wanted to confirm a few limitations.

  1. Can’t load mid-scene?
    I can easily save anywhere and load from anywhere, but the game always loads at the beginning of the scene where it saved.

  2. Can’t use variables to name saves?
    For instance, using the player-chosen character name as the default save name causes an error.

I’m not complaining about either of these things. In fact, I’ve already more or less worked around them. I just wanted to make sure it’s not my own stupidity overlooking something obvious. :stuck_out_tongue:

@CS_Closet you can load mid scene I did it in unnatural it autosaves at a midway point and you can load it up from that point.