ChoiceScript Saving Plugin (Update: April 2023)

I’m going to try this in my own game. Thanks, @CJW

1 Like

@Farside Glad to hear it, let me know how it goes! :smiley:

@Nocturnal_Stillness Redownload the file, I’ve got a rough workaround working (or it seems to be working).

Don’t forget to change “mygame_save” !!! :confused:

I’d make it automated but I can’t think of anything specific to a game (for identification) that won’t change. They all use dropbox so the website is no good, we all change our titles too often.

Maybe just a variable change, as opposed to 10-12 instances of the word.

1 Like

Drastically simplified the “mygame_save” situation, now all you need to do is open up save.js and locate the following at the top of the file:

saveMod = { isLoadingLS: false ,mygame_save: null };

And change the ‘null’ to the name of your game (or some personal identifier (the more abstract the better)) enclosed in quotation marks, for e.g.:

saveMod = { isLoadingLS: false ,mygame_save: "terminal" };

This just ensures the system saves to localStorage keys specific to your game and prevents all the people using this system from overwriting each other’s saves.

An error prompt should appear if you forget to set this, so hopefully it won’t be too easy to forget.

A word of warning: pick a simple value and stick with it, don’t keep changing it as you’ll break everyone’s saves with the old identifier(s).

1 Like

u rule i added it to all the games i am making or helping with and ur name will be in all of the games

1 Like

Dear Santa,
Forget the list @CJW already took care of it.

This is beyound cool… words can not fill the sheer joy of this.
lol
Thanks.

1 Like

Thanks @CJW you did it again!!! You are a great member of the community

1 Like

That’s great @CJW have installed that in the game I am working on and it is working very well :slight_smile:

One question though, is there a way (since i’m not terrible familiar with JS programming) to add some space below the ‘clear save’ and ‘load’ buttons so that the main game text isn’t butted up quite so close to it?

EDITTED: It’s okay - i’ve sorted it :slight_smile: Many thanks for something that a lot of people will find very useful, I will make sure to credit you in my game.

1 Like

Thanks guys! Please let me know how it goes, and don’t forget to set mygame_save!!

1 Like

@CJW took me the all of 3 min. to install works perfect so far. I did not have to strain my head at all. lol This is really nice and a hugh thanks man.

1 Like

Very helpful. The great CJW has done it again.

1 Like

@lordirishdas - I’m very glad to hear that, it’s what I was aiming for! :slight_smile: Thank you!

@TIYF I’m glad you think so, thanks!

Update

  • In relation to @Nocturnal_Stillness ’ issues yesterday I’ve restructured the loading function. It now has its own method “restore_localStorage” as opposed to overwriting “restore_password”, so despite it being based on the password functions, they shouldn’t ever clash or cause problems with each other - please let me know if they do.

This has also allowed me to remove the shoddy isLoading boolean work around and allowed me to do away with the automatic password page completion (we just parse everything without it now).

TL;DR Version: I’ve optimized and simplified the code, as well as supposedly making it more reliable and easier to debug in the future.

Your player’s saves will not be affected as long as you remember to copy the mygame_save value to the new save.js file.

As always, if you encounter any problems please let me know! I’ll also begin to consider any improvement suggestions (should you have any), seeing as the basics seem to be stable at the moment.

1 Like

@CJW

Is there anyway to move the two buttons inline with the others?

@Nocturnal_Stillness - Yes, would you prefer that?

@CJW

Yes I would, personally I think it can be a bit too close to the game text. It’s not terrible and I can live with it like it is. (Just thankful for having it in the first place!)

I’ve actually included a padding value in the latest version, so it’s spaced away from the text, but I can make it inline with the others, no problem.

Edit: Moved load and clear buttons inline with stats and restore game buttons.

Turns out Internet Explorer doesn’t support localStorage for local files (it works fine online), so I’ve recoded it to prevent initialization if IE is being used for offline/local testing, saves you having to disable the mod manually.

@CJW thanks!

1 Like

It occurred to me that it might become somewhat annoying if you had to overwrite your saved game every time you restarted, whatever the reason.

To this end I’ve added a third button that reads ‘Enable’ or ‘Disable’ - Autosave as appropriate, so you can turn off the automatic saving (and prevent overwriting of your saved game), should you so desire.

The game author can determine whether the autosave is on by default or not at the top of save.js (the default default is that autosave is disabled).

The changes can be seen in the demo:
https://dl.dropbox.com/u/7840892/CJW/choicescript/mods/localStorageSave/web/mygame/index.html

And the source file downloaded here:
https://dl.dropbox.com/u/7840892/CJW/choicescript/mods/localStorageSave/save.js

Working in IE9+ Chrome and Firefox

I’m considering implementing save “slots” if there’s enough interest in the idea, so if you’d like them (and can think of any specific parameters) please let me know.

Thank you

1 Like

Have tried on the new save.js file but I just get a “script error” message whenever I attempt to click on the enable/disable autosave button, it functions fine if enabled or disabled within the save.js file, it just seems to be the enable/disable button that doesn’t work - I have tried replacing the ui, style and index files I was using with the choicescript defaults and running it, I still get the same result though.

Any suggestions?

What browser are you using?

There are some issues with IE8 and anything below that doesn’t support localStorage.