Autoloading a different html file's save?

Twine 2.35, Sugarcube 2.31

Hey so one of my twine games is loading data from a different game.

  1. I made both games using the same root twine file (offline), saved them with different names and then uploaded them to my server. They are in the same folder.

  2. Both games have this in the Javascript section:

Config.saves.autosave = [“bookmark”, “autosave”];
Config.saves.autoload = “prompt”;

  1. What’s happening is that I play game A and make some progress. But then when I want to play game B it actually doesn’t start at the beginning of B, but instead loads the save of game A!

- Is it possible to have these two games NOT interacting with each other in this way?

I’m guessing I could just have them as totally different stories in twine offline, but A and B are kind of part of the same series (I might even have C and D etc.), and it’s really nice to be able to change a shared variable (or passage or css etc.) in one, and then just publish them to files with different names…

1 Like

I think you use this to configure the save file name.

1 Like

Thanks heaps! Interestingly, it seems that if I name the ids differently, B will still try to load the save file from A, but will realise that it’s from a different story, throw an error and force you to the natural start of B (assuming you had no actual B saves). This is sufficient.

Thanks so much for your help!

The storage key in SugarCube v2 is based upon a processed version of the story’s name/title—in their data chunk, what you name the files is irrelevant. Unless your stories have similar names, which might potentially reduce to the same storage key, they shouldn’t even be able to see each others data.

Thus, I’d ensure that their (internal) names are actually different.

PS: Please also ensure that you aren’t reusing the IFID, which should be unique between stories.

1 Like

Thanks TME,

When you say “internal names” what do you mean exactly? Are you saying they still have the same internal name even if I publish them to file (on PC) with different names? One was called “prompt” and the other one was called “full”, so that does seem pretty different.

Hmm I’ll have to look up the IFID. Not sure what that is haha.

Does this mean I can’t really do what I’m trying to do though (ie have 1 story in twine and then publish 2 different stories from that same file)?

I guess I’m just trying to save time because if I just duplicate the first story file (A) into another story (B) and then make any changes to A, that means I have to switch over to story B and make those changes there as well, which is super painful. If I have C and D etc. you can see how this really gets out of hand.

I’ve heard Tweego might be a good solution for this kind of thing - can you reccomend anywhere to start investigating this kind of workflow?

Are you using Tweego or the standard Twine editor? I’m assuming you’re using the standard editor since you’re not sure what the IFID is (it’d be pretty obvious if you were using Tweego).

If you’re not aware, Tweego is a command line compiler for Twine. The big (and only) feature that you lose with Tweego is that it doesn’t provide any visual mapping of your story. You edit everything in a standard text editor and then send it to the Tweego compiler to compile into a playable HTML file.

The reason I bring all of this up is because one of the big features Tweego has over the standard Twine editor is that you can pass multiple files to the compiler. This lets you break up your story into multiple javascript files, CSS files, and most importantly .tw files (the twine story files).

This helps keep your story organized as it gets bigger, but the main thing here that could help you is that you can share those file from project to project. So you could edit files that are included in both story A and story B just once. You’d have to recompile the stories after an edit, obviously, but that’s just a single command per story instead of copying everything and hoping that you don’t make a mistake.

1 Like

Yeah sorry I’m not using Tweego. Although I’m thinking from your description that maybe I should!

This helps keep your story organized as it gets bigger, but the main thing here that could help you is that you can share those file from project to project. So you could edit files that are included in both story A and story B just once. You’d have to recompile the stories after an edit, obviously, but that’s just a single command per story instead of copying everything and hoping that you don’t make a mistake.

Honestly that sounds amazing! Would you recommend any tutorials for tweego for a complete noob like myself? :stuck_out_tongue_winking_eye:

It’s just a compiler, so there isn’t much needed in the way of tutorials.

Here’s the program:

And its docs:

To go from where you are now to a tweego setup, the easiest method is to export what you have now to an HTML file (not your compiled game, but actually export it using the twine editor). Then on the command line in same directory as tweego, you run this command:

tweego -d -o new_story.twee old_story.html

That’ll output a text file with your game written in twee notation. You may have seen people post examples using :: to denote a passage in “twee notation format”. That’s what we’re talking about. That’s the format that tweego takes.

You can see other examples of how to use it from a command-line here:

1 Like

Ok this looks amazing, thanks so much! I’ll have a go this weekend. Exciting times! This could save me 100s of hours. Thanks!

1 Like

Oh. One little heads up for you.

After you convert your old file to the new format and then run that file through the compiler to compile, it’ll most likely throw an error. That error will be regarding a missing IFID (which TME was talking about earlier). It’ll display some code on the console containing an ID. Just copy the code that it spits out into your file and then run the compiler again and you should be good to go.

1 Like

Depending on how you’re duplicating your stories, they may have the same (internal) story name—what you named the original story in Twine 2 when you created it—regardless of their (external) file name. When I said “(internal) names” before, I meant the story names.

Simply giving the same story different file names does not change its story name. That’s why I said you should ensure that their story names are actually different.

Because of the way SugarCube v2 creates the storage key used by stories, unless they have the same story names, or are similar enough to reduce to the same storage key, two stories literally should not be able to see each others in-browser saves. Thus, I suspect that your stories have the same, or very similar, story names, regardless of their file names. Certainly, if their story names were actually “prompt” and “full”, then they should not be able to see each others in-browser data without something very serious going wrong.

1 Like

Further to TME’s comment.

If you look at the meta-data section of a Story HTML file generated by the Twine 2.x application it will look something like the following… (simplified example)

	<tw-passagedata pid="1" name="FIRST PASSAGE NAME" tags="" position="100,100" size="100,100"></tw-passagedata>
	<tw-passagedata pid="1" name="SECOND PASSAGE NAME" tags="" position="100,100" size="100,100"></tw-passagedata>

…where the “CAPITAL LETTER” values are obviously replaced the related values from the Story project.

So if the <tw-storydata> element of two (or more) Story HTML files have the same name and ifid values then they are considered the same Story project.

1 Like

Ok I think I get it now. Thanks heaps! So basically using the “publish to file” option doesn’t change the Story name or the ifid even if I’ve saved the file under a different name.

Ok thanks, that’s really good to know. Sorry I was just confused about “story name”. Up til now I thought that meant the name of the html file.

My question is related to this topic…and I’m using Twine 2 / Harlow 3.1…

Nothing would be more frustrating I think than getting half-way in to a story/game only to find you can’t save your progress.


Is there a way to do a check if the browser accepts (third-party?) cookies so the player can be alerted that cookies are required before a game can be saved - preferably prior to any attempts thus possibly preventing the aforementioned scenario?


PS…Think it has already been answered and is a ‘No’, but lets say the player gets to the end. Is there a way to save a file containing data such as inventory and stats that could be imported into a sequel?

FYI: Harlowe’s Save system doesn’t support the usage of Cookies to store a story’s progress or Saves, only they web-browser’s Local Storage cache.

The story format also uses a different method to identify the Saves contained within the Local Storage cache, and depending on the circumstances that method can result in Saves created in one story:

  1. being loadable by a different story.
  2. overwriting the Saves of a different story.

Harlowe has no built-in means for doing this, but you can use JavaScript (and a JS File library) to add such functionality as long as you’re comfortable with hacking the story format’s engine to gain access to its internals.

…or using an add-on like Chapel’s Unofficial Custom Macro Framework for Harlowe which does (some of) that hacking for you.