Saving between sessions

What I want is for the browser to remember where the player was, so that my game can be played in multiple sessions (or survives an accidental browser closing). I’ve delved into the forums and the wiki a bit, but the situation has left me quite confused. If I understand it correctly, what I should be using is the smPlugin.js introduced here:

However, the links in that post no longer work, leaving me both in need of the file and some tutorial information. I think I managed to find the javascript file itself here:

But I’m not sure how to use it. From some forum post I can’t immediately find any more, I got the idea that I had to include the Javascript file in my index.html, under some other javascript inclusions. However, the index.html in the ChoiceScript folder contains no javascript inclusions, as far as I can see. The compile.hmtl file does, but adding it in there didn’t seem to work.

Any help would be greatly appreciated!

You will probably host your WIP on dashingdon, so the best way to implement a save system is to simply use their integrated one.

After you upload your wip there, there is an option to enable save mode, and it will ask you to insert a code on your game (I think the code is provided on that same panel) so you simply need to add it to your startup file.

3 Likes

Nope, this is a game written for the Interactive Fiction Competition. It will be hosted on their website and also be distributed as a stand-alone html file.

Ah well, no clue then. Never tried importing it to a file.

CS games save their session via caching. In the instance where you get the game from 3rd party platforms, CS runs the game on its own “separate browser,” preventing mix up with your original browser.

That being said, I don’t know how to enable that if you plan to host the game somewhere else.

There’s a line in web/mygame/index.html:

// INSERT store name; disabled by default because it's confusing for newbie authors
window.storeName = null;

You can set that storeName to something of your choice; use all lower case letters, no spaces.

window.storeName = "victorgijsbers";

From then on, the game will preserve state when you refresh the page.

I recommend leaving this off (leaving it null) during development of the game, because it can be very confusing to preserve state while you’re rewriting.

When people submit Hosted Games to us, we turn it on ourselves when we post the game to our web site.

5 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.