ChoiceScript Saving Plugin (Update: April 2023)

So I just played around with the save mod - which is long overdue:

I have a strange case with having the *sm_init as the first line of code. It seems to display anything below the code even if it is a command.

Here in my build I’m in the second txt file after I finish a first chapter and I wanted to assign an autosave. This is the topmost bit of the txt:

*sm_init fcasaves | 5
*set para1 xx
*set para2 xx
..
..
..

The first page of this chapter would display the *set para1 xx in the narrative. It showed up like

*set para1 xx

The first sentence of the narrative goes here..... like it normally would

When I moved the *sm_init away from line 1 and put it somewhere in between my dozens of lines of variable setup (before the first narrative is displayed to the screen), it fixed the stray printout. The *set para1 xx would stay off screen.

As sidenote, I added alertify.min.js and its css to the directory and linked them to index.html manually - I’m still using the CS engine I downloaded before the whole alert pop-up thing was deployed, but I’m not convinced that’s the problem source. The autosave itself seemed to work just fine with *sm_save 0 | false | Autosave which displays nicely after a radio button as “Autosave” when the slot menu is brought up.

@FCA Your issue is only when it’s the first command? Does it work fine anywhere else?
@Kurisu That’s odd. I’ll take a look and get back to you! :slight_smile:

@CJW From what I can tell, yeah.
So like, as with anything that’s system/backend-related, I thought it’s best to stick these kinds of commands up top before the rest of the code? A command line showing up along the story is definitely something new for me.

The save works fine (…so far, only half an hour in :smiley: ), I use a portion of your example txt to present a Load-Delete menu at the beginning of the first scene file - I call it ‘chapter’ in my narrative. The progress is saved right where the *sm_save is placed in the second scene file, and it loads back without problem.

It’s on Firefox 21, if it helps.

Edit: Would you happen to know if there is any character-type limitation for the slot name? Alphanumeric only, can’t use special signs { }, stuff like that? I think Javascript is usually not very forgiving on that.

So I poked around and as @Nocturnal_Stillness said, you simply need to use it after any *create, *title or *scene_list commands - I can’t really change that, it’s just how CS’s interpreter has been coded, it’ll throw an error if you use any command before those initiation ones.

@FcA @Kurisu
That should solve both your problems, but let me know if it doesn’t.
FcA you should be able to use most typical characters as the data is stored as a string.

Good Example:


*title Mygame
*scene_list
	startup
	prologue
*create leadership 50
*create strength 50
*sm_init mygame | 5

Bad Example:


*title Mygame
*scene_list
	startup
	prologue
*sm_init mygame | 5
*create leadership 50
*create strength 50

Bad Example:


*sm_init mygame | 5
*title Mygame
*scene_list
	startup
	prologue
*create leadership 50
*create strength 50

Just starting to notice a few other bits and pieces wrong with the save system actually, so if you use the plugin please check back for an (advisable) update in the near future.

I might just rewrite the entire thing actually, so if anyone has any feature/ease of use requests - now would be the time! :slight_smile:

1 Like

I just updated smPlugin.js and would advise anyone using it to overwrite their old one with this version. You shouldn’t notice a functional difference, but everything is tidier and the inbuilt errors should finally work as intended - making future bug fixing a lot easier.

Arguably it should also support older browsers that can only utilize cookies now, but I was having trouble proving this (as I can’t seem to get a proper copy of IE7 installed on my machine).

The link is here: https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/smPlugin.js

And if for some reason you do end up having any problems, the current (old) version is now here:
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/archive/smPlugin-08-05-2013.js

1 Like

@CJW @Nocturnal_Stillness
Thanks, that seemed to fix my problem.

I have another minor issue that came up though, I don’t seem to be able to assign a name to the hidden auto-saves I make for the player at the end of every chapter.

Example:
*sm_save 0 | false | End of Prologue

Still gives me the default auto-save name with the date and time. Making it not hidden works as intended, though. Any ideas?

1 Like

@CJW Thanks so much for going the extra mile fixing that! I’ll be trying out the updated version in a bit; gonna take a while to come back here with a feature request, if any.

@Kurisu I place an autosave at the beginning of the next chapter instead, if it helps. The custom name I assign for the target slot works okay.

1 Like

@Kurisu Small bug/oversight in the update, it should be fixed now if you want to redownload it.
@FcA Anytime! Thanks for using it! :slight_smile:

1 Like

@CJW
Thanks, worked like a charm.

Pardon me for being so late to the proverbial party, but can you summarize what I’d need to do to get save slots for my game? I’d read through the 4 pages here, but my attention span just isn’t there…sorry.

@DaveDPF
That’s about as simple as I can describe it:

Remember that all this does is give you some new commands, it’s up to you on how and where to use them - there isn’t really a right or wrong way! :slight_smile:

If you’re still struggling, check out the demo:
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save-framework/index.html

The code for that can be found here, and should work out of the box, once you’ve included smPlugin.js.

Just remember to edit index.html and add the following line at the top, beneath the similar lines for scene.js ui.js etc:
<script src="../smPlugin.js"></script>

And of course, to actually download and put smPlugin.js in your ‘web’ folder along with ui.js and scene.js etc.

I’ve a quick question to anyone who uses this, is thinking of using it, or even just plays a game that uses it. It’s related to a thought I had the other day.

Would you prefer the save fields/options to be completely incorporated into the CS interface, or are you quite happy with them in the alert/pop up box format?

The following screens will hopefully illustrate the idea:

Menu:

Naming:

Confirmations:

Deletions:

Would incorporating it into the CS system allow CoG to add it to their games?

They don’t need to add it, in published apps their propriety save works just fine, better even, as the apps save state and saves can be uploaded/downloaded to various devices. The only downside (in my opinion) is the lack of deletion - which I’m sure they’re looking into.

I just can’t make it work I dowload smPlugin.js change index.html
don’t recognise sm_init command I put after create and before, no work in any form

@MaraJade It sounds like you’re not editing index.html correctly and/or you’ve not put smPlugin in the associated path.

If it’s easier for you, put smPlugin.js in the mygame folder (as opposed to the web one) and use the following line in index.html:

<script src="smplugin.js"></script>

Just insert it below all the other .js file inclusions.

Index.html would look like:

`

`

If you want it in your web folder, use:
<script src="../smplugin.js"></script>

no no working, the order in my index.html files is diferent could it be the problem?

Yes, smPlugin.js needs to load last. Check for any small syntax errors too, something simple like missing out a " or > can cause issues.

I copy yours and paste still don’t working

Can you PM me a link to the game, and I’ll try and see what’s up.