ChoiceScript Saving Plugin (Update: April 2023)

You need to open it in a text or code-editor, such as notepad or notepad++.
Right click the file and select ‘open with…’, then follow my above instructions.

Apologies for the necro, but I was hoping you might be able to help me with the issue I’m having, as I’ve been at it for over an hour now with no luck. The issue I am having is when I enter the new line of script into the index.html, I can’t seem to get the grey next button to work afterwards, clicking it does nothing.

I am placing the smplugin.js under mygame.js (and generally speaking, I haven’t altered the script order from the original), the syntax is all correct, the js file is definitely in the right directory with the right pathing (I put it in both folders to make sure), and sm_init is in the correct place under all the *create’s with the variables set.

It isn’t throwing up any error codes, it just won’t let me click through to the next scene. As soon as I remove the line from the index.html (and the *sm_init), it works fine again. Suspect it is a general issue, as when I couldn’t get the advanced save working, I tried the earlier save plugin and had the same problem. Anyway, any ideas you may have would be greatly appreciated, stumped over here.

EDIT: Forgot to mention, have tried both with IE and Firefox (up to date versions) and both doing it.

I want to add a save system to my game where a beta-tester can save at any time of his choosing. The smPlugin system will work for this if I add a save #option in each and every *choice. Obviously that’s not ideal, so I thought I could put the save/load/delete menu on the stats screen. However, this seems to restore the game to the stats screen itself, and then I can’t get back to the game. Is there a way to do what I want? Perhaps by making another button next to Show Stats and Achievements?

Would autosave.js not suffice for this?
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/autosave-plugin/index.html
https://dl.dropboxusercontent.com/u/7840892/CJW/choicescript/code/save.js

Wow, I see there are buttons for it at the top, but it only saves your current place. How hard would it be to make a Save button at the top to call *sm_save? That’s pretty much what I’m looking for.

BTW, in the autosave example index.html, if I hit restart, I get: Uncaught exception: ReferenceError: Undefined variable: alertify

I think I figured out how to do it myself:

< button id=“saveButton” class=“spacedLink” onclick=“Scene.prototype.sm_save(‘0 | true’);”>Save< /button>

However, if I load a game (using a *choice block much like your example), then hit the Save button after playing a little further, nothing happens. I have to hit it again, and then it saves correctly. Any ideas why that might be happening?

Here’s the code at the beginning of startup.txt (after all *create’s) that does the loads:

[code]
*if debug
*sm_init dragon_princess | 11
*label sm_top
*choice
#Play from the beginning.
*goto sm_done
#Load
*label load
*choice
#{savemod_slot_0} *sm_load 0 | false *goto sm_done #{savemod_slot_1}
*sm_load 1 | false
*goto sm_done
#{savemod_slot_2} *sm_load 2 | false *goto sm_done #{savemod_slot_3}
*sm_load 3 | false
*goto sm_done
#{savemod_slot_4} *sm_load 4 | false *goto sm_done #{savemod_slot_5}
*sm_load 5 | false
*goto sm_done
#{savemod_slot_6} *sm_load 6 | false *goto sm_done #{savemod_slot_7}
*sm_load 7 | false
*goto sm_done
#{savemod_slot_8} *sm_load 8 | false *goto sm_done #{savemod_slot_9}
*sm_load 9 | false
*goto sm_done
#{savemod_slot_10} *sm_load 10 | false *goto sm_done #{savemod_slot_11}
*sm_load 11 | false
*goto sm_done
#Return
*goto sm_top
#Delete
*label delete
*choice
#{savemod_slot_0} *sm_delete 0 *goto delete #{savemod_slot_1}
*sm_delete 1
*goto delete
#{savemod_slot_2} *sm_delete 2 *goto delete #{savemod_slot_3}
*sm_delete 3
*goto delete
#{savemod_slot_4} *sm_delete 4 *goto delete #{savemod_slot_5}
*sm_delete 5
*goto delete
#{savemod_slot_6} *sm_delete 6 *goto delete #{savemod_slot_7}
*sm_delete 7
*goto delete
#{savemod_slot_8} *sm_delete 8 *goto delete #{savemod_slot_9}
*sm_delete 9
*goto delete
#{savemod_slot_10} *sm_delete 10 *goto delete #{savemod_slot_11}
*sm_delete 11
*goto delete
#Return
*goto sm_top

*label sm_done[/code]

Quick Note: smPlugin.js (and likely save.js) don’t seem to be compatible with the latest version of CS. So either don’t update your game until I push a fix or remove the reference to the mod(s) from your index.html file (if you’re having problems with unresponsive page_breaks and choices etc).

Update: I’ve not tested it extensively, but I believe the issue should be fixed now.
Please let me know if any of you run into any further problems.

@Flurrywinde11
Sorry, I must have missed this. I have no idea though I’m afraid, it’s not something I ever thought to try.

This works perfectly for me. Thank you so much for making something like this! Its easy and a lifesaver!

1 Like

Update: smPlugin - Menu Addon

Due to what seemed like an increasingly popular demand I’ve thrown in the towel and finally written an ‘addon’ for smPlugin that provides an interface for your game so that players can save games ‘on the fly’ - much like they would usually be able to in visual novels and the like.

With thanks to @Malebranche for the idea and design:

It’s very easy to use, simply download and include the smPluginMenuAddon.js file in your index.html (BENEATH smPlugin.js - you do need both files!), run your game and after 3 seconds or so the buttons and slot selection should appear and function as intended.

Note that you do still need to use *sm_init on the first page of your game to initialize your slots and game id - that is extremely important!

Other than that the addon should do the rest for you, though you can of course still use the smPlugin.js core commands, if you want to make an autosave or the like (just make sure you tell your players which slots you’ll be overwriting!).

If at any point you want to be cruel and disable saving you can also use the extra command:

*sm_menuaddon false

And of course, to re-enable saving:

*sm_menuaddon true

File

Enjoy!

P.S.
This addon (in my eyes) makes save.js all but redundant, so unless there are any complaints I’ll be considering discontinuing support for that rendition of the mod.

10 Likes

@CJW Wow this is amazing, you deserve huge props for the time and effort put into this! Unfortunately, i find myself a little bit confused as to how you’re meant to declare *sm_init. I’ve scrolled up and looked through previous responses hoping to find the answer hidden somewhere in this thread, but I haven’t been able to find anything.

I’ve downloaded and included smPlugin.js as well as smPluginMenuAddon.js is my index file:

And I’ve used *sm_init on the first page of my game as such:
*sm_init Song_Of_The_Fallen | 3

*title Song_Of_The_Fallen
*author Left4Bed

*scene_list
startup
Chapter2
Call

However unless I remove *sm_init Song_Of_The_Fallen | 3 I get this error.

I suspect this is because I really just don’t quite understand what you mean when you say:

I’m sorry if this is a stupid question.

Same thing happened to me when I first downloaded, turns out you need to put it right before your story exposition starts after all the *create commands and everything in startup.txt.

1 Like

@Malebranche Which *creates are you referring to?

*create strength 50 *create otherstat "" Those ^^ at the beginning of your startup.txt file after the scene list. The *create command is for your global (or constantly used) stats.

So under all my stats and before any exposition, I’ve added *sm_init Song_Of_The_Fallen | 3. Song_Of_The_Fallen is what I’ve put as my game_id in smPlugin.js with a slotCount of 3. But now it’s throwing up this error.

Which is strange since I added both of those to my index file? I added it to the index file in the mygame folder since the one in the web folder doesn’t seem to have anywhere for me to put it. I did the same thing for the original save.js system that began this thread, and that worked fine. I’ve also placed copies of smPlugin.js and smPluginMenuAddon to both the mygame folder and the web folder.

Reading up, specifically looking at what @Flurrywinde11 posted, I get the impression that you’re also supposed to declare *sm_load and sm_save? I’ve also fiddled with the quick-save-menu .zip folder @CJW linked to in another thread, but to no avail.

So you have a copy of each one in the mygame & in the web folder (4 files in total 2 of each)?

Yes, but the error comes up either way. You say you’ve manged to get it working? Is there any chance i could see a snippet of your relevant code?

I only have 1 copy of each, placed within my web folder, like so:

In index.html:

And in startup.txt:

That’s pretty much exactly, what mine is…which index file did you edit?

The one in the mygame folder.

Still throws up the same error, though it also throws up this.

I’m downloaded the lastest version of choicescript from the website and I’m busy updating my firefox, hopefully that’ll have some effect, because as far as I can tell we’re doing exactly the same thing.