ChoiceScript Saving Plugin (Update: April 2023)

If you’re hosting on Dashingdon with a game that isn’t compiled, I think all you have to do is include the command:

*sm_init mygame | 3

at the beginning of your first scene file. Then check the little box on the Dashingdon ‘edit game assets’ page to enable the save slot system. I have my first scene file in a different .txt file to startup.txt, so I put the *sm_init command at the top of that first scene.

There are instructions on the Dashingdon ‘edit your game assets’ page, too. And then you’ll be good to go with save slots!

Will that suit, or do you need it to work in a compiled game? Or did you want to have specific save points? If so, you can also have a look at this post.

9 Likes

I did exactly that and it worked like a charm. Thanks for the tip, it was way easier than I expected it to be!

2 Likes

I will try it this weekend! Thanks for the guidance!

1 Like

For sure! @dashingdon’s support for the save system in the hosting service has made using the plug-in even more convenient and accessible, which is great.

I usually comment out the *sm_init line when I’m writing and coding, since the autotests don’t get on with it, and then enable it again when I’m ready to upload the new material.

2 Likes

Will I need to have save.js downloaded in order to work smPlugin and the menu addon?

No, save.js is an old iteration. Use smPlugin.js and, optionally, smPluginMenuAddon.js.

I’ve made a tiny change to smPluginMenuAddon.js that should fix a bug where the menuAddon would always initialise with 3 slots, regardless of the *sm_init parameter, outlined here:

If you’re happily using 3 slots, there’s no rush to update, but there’s no harm in it either! Just download the file via the same link and replace :slight_smile: @dashingdon

4 Likes

Pssstt… 6 slots :"

1 Like

I can’t seem to get the saving system plugin to work with the very latest version of ChoiceScript. When I try to run the game in Firefox, it gives me the error: ‘Non-existent command ‘sm_init’’.

It’s either probably because:

  1. You forgot to include the
    <script src="../smPlugin.js"></script>
    <script src="../smPluginMenuAddon.js"></script>
    lines to the index.html
  2. You forgot to include the
    smPlugin.js
    smPluginMenuAddon.js
    files to the /web/ directory
3 Likes

@Szaal Ah yes, you are right, I made a mistake with the index.html file. All sorted; thanks for the rescue!

2 Likes

Anytime :ok_hand:t4:
You’re lucky that I’m around this time.
*puffs out chest, hands on hips

2 Likes

@CJW Sir, you are a lifesaver! I very much enjoy your choicescript API also.

1 Like

Glad you like it. What do you mean by ChoiceScript API though? I wasn’t aware I’d wrote one! :face_with_raised_eyebrow:

I meant choicescript IDE.

1 Like

Ah! Sorry for being pedantic, I just wanted to be sure I wasn’t being credited for someone else’s hard work! :slight_smile:

I’m very glad you’re finding them of use, and please don’t be shy about sharing feedback (good and bad)!

1 Like

@CJW
@Malebranche

Hi, I hope I’m not causing an issue by posting in this thread. I’m running into a bit of an issue. I’ve read through everything in here, top to bottom. I can’t seem to get this working.

What I’ve done:

  1. Download both files (“smPlugin.js”, “smPluginMenuAddon.js”).
  2. Place both files into the “web” folder, where “ui.js” already exists.
  3. Go into “mygame” folder. Open “index.html”.
  4. Add the following lines (in exact order) to the “index.html” file, making sure that they come after the other “.js” files in.
<script src="../smPlugin.js"></script>
<script src="../smPluginMenuAddon.js"></script>

So they actually look like this:

<script>window.version="UNKNOWN"</script>
<script src="../version.js"></script>
<script src="../persist.js"></script>
<script src="../alertify.min.js"></script>
<script src="../util.js"></script>
<link href="../style.css" rel="stylesheet" type="text/css">
<style id="dynamic"></style>
<script src="../ui.js"></script>
<script src="../scene.js"></script>
<script src="../navigator.js"></script>
<script src="mygame.js"></script>
<script src="../smPlugin.js"></script>
<script src="../smPluginMenuAddon.js"></script>
<link href="../alertify.css" rel="stylesheet" type="text/css">
  1. Save the “index.html” file, and close it.
  2. Go into the “scenes” folder. Open “startup.txt” (or first file).
  3. Place “*sm_init” between the variables created and the start of the story text.
*create control_world false

*sm_init 

Chapter One: A Sloppy Beginning
  1. Save and close file. Return to the “mygame” folder.
  2. Right-click “index.html” and open with IE, Edge, or Firefox.

Problem:
For some reason, it won’t work. Did I miss any steps?

For step 4, I tried setting the two added scripts above the “mygame.js” script, and once above the “navigator.js” script.
For step 7, I’ve tried “*sm_init”, “*sm_init mygame | 3”, and “*sm_init The_Necromancer | 3”.

Errors:

  1. A popup window: “Unspecified error.”. I press OK.
  2. The drop down menu displays, but all three slots say “Error: Bad Slot - Has smPlugin been included?
  3. None of the story text is displayed at this point. Not sure if it is relevant.

I can provide screenshots if they are needed.

Thanks in advance for any help.

The files

<script src="../smPlugin.js"></script>
<script src="../smPluginMenuAddon.js"></script>

should go after scene.js , not at the end of the other .js files in the index.html file.

The format for the *sm_init command is as follows:

*sm_init [gamecode] | [number of slots needed]

Yeah, I tried them once between “scene.js” and “navigator.js”.

It’s actually where I’ve left off. It’s not working. D:

EDIT: This is supposed to work in one of the browsers right? It’s not just something for DashingDon?

EDIT 2: What is the game code? Is this something we can make up?

Yes, it’ll work in a browser as long as you’re using your copy of CS with the modified files in index.html.

The ‘game code’ is essentially a unique identifier for your game. So, if your game were called Endless Fountain and you wanted three save slots, the *sm_init line might look like:

*sm_init endless_fountain | 3