ChoiceScript Saving Plugin (Update: April 2023)

@Spindraft
It will work in all browsers if you’re game is hosted online. I can’t help, change or bypass the fact that many of them place restrictions on certain features when running js in a local environment.

Search for Dropbox and/or dashingdon hosting. These are the two methods most of the authors here use to publish their games online.

@Lycoris
Hi, sorry about that, I just noticed the image links are broken. Yes you should essentially just copy one of the other script lines in its entirety and replace the href=“myjsfilepath” with the path to your copy of smPlugin.js. Don’t forget to include a copy of the file, else you’ll be referencing nothing.

I can’t find it :disappointed: Also, how do you get the path to the smPlugin.js? :open_mouth:

My, I’m terrible when it comes to things like that.

*chuckle * :grin: That’s because there is not an actual line in the index file (and make sure your editing the index file in your mygame folder) that reads < script href=“myjsfilepath”>< /script>.

What CJW-senpai (<- I apologize in advance CJW, it was far too tempting not to) was saying is that you should copy one of the other < script> tags in its entirety, for example like this one: < script href=“…/scene.js”>< /script> (of course, make sure to remove the spaces in this script tag here before the “<”'s otherwise the script tag I give here won’t work) paste it in a new line with the other < script>'s, and replace the stuff in href=“blahblah” (or href=“…/scene.js”) in our example with the path to the smPlugin.js file.

Now regarding path, if you put it in the web folder, like you should, since it’s where all the other .js files are, since the index file we’re editing is in the mygame folder that’s in the web folder, your file path would be “…/smPlugin.js”, the “…/” is basically shorthand for “it’s in the parent folder of this folder” and so on and so on, so let’s say if you put the smPlugin.js file in the main dfabulich-choicescript-[insert-random-version-number-here] folder, your file path for it’d be, “…/…/smPlugin.js” since it’s in the main folder that is two folder levels separated from the index file in the mygame folder.

Does that make sense?

2 Likes

Thank you for your help! :blush: I’m just a big idiot when it comes to coding :disappointed:

Right now it looks like this

[code]

<-------This! [/code] Of course, the "<--------This!" is not in the actual file :smile:

So, like this? :open_mouth: the save mod is in the same folder as ui.js and scene.js, but I don’t see the save feature yet. I’m doing something wrong? :disappointed:

Well, what save feature did you want? The one with the “save” “load” “delete” bar on top? Or just the normal save system where you save via a choice in game?

I wanted the one with “save”, “load” and “delete” bars :blush:

Oh, for that you need the SmPluginMenuAddon.js file as well, and you need to follow the same procedure as before. The link to it ought to be at the bottom of the OP. To download the file (since it just shows up, but doesn’t auto download), just add ?dl=1 to the end of the link, that’ll trigger the file download from Dropbox’s end.

1 Like

@Malebranche

Do they mean this bit here?

saveMod = { mygame_save: "0" //Change null to the name of your game inside quotation marks, for e.g. : ,mygame_save: "terminal" //This ensures your game saves are unique to your game and won't be overwrote by anyone else using this system. ,isLocalIE: false //Don't change this ,autoSave: false //true = Autosaves by default - Otherwise player must activate autosave. };
Like, if my game is called “The Freakhouse, A Touch Of Lilium”, can I just do this?

saveMod = { mygame_save: "freakhouse" //
By the way, I tried using the *sm_init command, but it doesn’t work :disappointed: The command is “non-existent”.

I’m very sorry I’m so annoying :disappointed_relieved:

Uh oh, have you actually edited that file in that way? And for me to understand on my end, which file’s code are you looking at? In my game I didn’t need to touch the .js files,only use *sm_init like this:
*sm_init tempestten | 5
of course replace “tempestten” with your game’s name.

Actually, if you’re comfortable with it, could you copy paste the first part of your startup.txt here? It’d let me see what you’re doing and help direct better.

Nah, it’s all good.

1 Like

The startup starts like this:

[code]*label top
*sm_init freakhouse | 4
*choice
#Save
*label save
*choice
#{savemod_slot_0} *sm_save 0 | false *goto top #{savemod_slot_1}
*sm_save 1 | true
*goto top
#{savemod_slot_2} *page_break *sm_save 2 | true *goto top #{savemod_slot_3}
*sm_save 3 | true
*goto top
#Return
*goto top
#Load
*label load
*choice
#{savemod_slot_0} *sm_load 0 | false *goto top #{savemod_slot_1}
*sm_load 1 | true
*goto top
#{savemod_slot_2} *sm_load 2 | true *goto top #{savemod_slot_3}
*sm_load 3 | true
*goto top
#Return
*goto top
#Delete
*label delete
*choice
#{savemod_slot_0} *sm_delete 0 *goto top #{savemod_slot_1}
*sm_delete 1
*goto top
#{savemod_slot_2} *sm_delete 2 *goto top #{savemod_slot_3}
*sm_delete 3
*goto top
#Return
*goto top
*page_break

*title The Freakhouse

*author S. P. aka Lycoris

*scene_list
startup
prologue
welcome
the_show_begins[/code]

The index file from mygame folder:

[code]

[/code] The save.js [code]saveMod = { mygame_save: "freakhouse" //Change null to the name of your game inside quotation marks, for e.g. : ,mygame_save: "terminal" //This ensures your game saves are unique to your game and won't be overwrote by anyone else using this system. ,isLocalIE: false //Don't change this ,autoSave: false //true = Autosaves by default - Otherwise player must activate autosave. }; [/code] The game says that the *sm_init command is non-existent and won't work :disappointed:

I think I see the problem, move the *sm_init command under *title *author and *scenelist. That should help. Also, save.js is redundant there since you have smPlugin.js already there, there’s no need for a second save system.

1 Like

Nope, it says

startup line 12: Non-existent command 'sm_init'

:disappointed:

Also, what about the save.js? :open_mouth: It’s the plugin, right? And you need it for the addon to work, no?

I have seen it in games like “From Ashes We Rise”, by @Wraith and “Children of the Gods: The Hero Trials” by @Rohie, I wonder how they managed to get it right… :disappointed:

My bad, it should be “src=”, like the other script tags. Not “href=”.

If the commands are “non-existent” it means you’ve either got the path wrong in those < script > tags or you haven’t placed the appropriate .js file(s) in the web folder.

2 Likes

@CJW In which folder do I have to put smPluginMenuAddon then? :open_mouth:

In the web folder. Is the problem still persisting after you change the href= to src= ?

! No, it’s done! :grin: It works!!!

After changing href= to src= it still worked funny, and I had to update the save file with a newer smplugin file, but now it works like a charm! :smile: I’m so happy!!!

@Malebranche thank you very much for your patience! :blush:

@CJW thanks to you too! :blush:

3 Likes

@CJW
Thanks. Was just curious, no worries. CS made it sound like this had to be removed for publishing. Will look into the hosting deal.

@CJW Just installed it and it works fine after seeing post 295. This may be a stupid question that has been already answered but is it capped at 3 saves? Right now I have

*sm_init Candidate_3 | 5

but it only allows three saves.

Are you sure you haven’t got a space between “Candidate” and the 3? It should allow more than three, five in your case. Are using the menuAddon?

Yes I am sure I copied and pasted. I must have missed the menu addon