ChoiceScript Saving Plugin (Update: April 2023)

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?

@akatsuki9344

ā€œUnnaturalā€ is being the Guinea pig for the new save system.

@akatsuki9344 Thank you - Iā€™m just glad I can help! :slight_smile:

@Nocturnal_Stillness
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:

http://gyazo.com/fcea94ccb95b4c5380681e95a3b7b894.png?1356885980

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!

@bawpie

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.
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/smPlugin.js

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:
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/index.html

Demo Code
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/scenes/startup.txt

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.

COMMANDS:

*sm_init
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

*sm_save
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.

*sm_load
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

*sm_delete
Takes one argument, the slot number.

*sm_delete 1
*sm_delete 2

etcā€¦

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.

22 Likes

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.