Alternative Save System with Sugarcube [PassageFooter]

Hi! I’m not quite sure if this is the right place to ask a question of this sort, but this is pretty much the only active place answering questions about Twine and Twine story development. So I hope I’m not disturbing anything.

I’m currently helping a friend out in writing their story using Twine (version 2.3.14) using Sugarcube version 2.34.1. Most of it has been an absolute breeze and we’ve gotten to a level where it mostly is a really smooth experience. However, I admit, I may have tinkered a whole lot with it. To the point it’s not even really recognisable as a Twine game. But that’s beside the point.

I’m trying to create a sort alternative to the save system that already comes with Sugarcube, or rather using its functions in a more simplified UI.

While searching through the Internet for some help on this I came across this code in the Twine Cookbook.

:: StoryTitle
Saving Games in SugarCube

:: Start
<<script>>
if (Save.slots.has(0)) {
  State.variables.slotA = true;
} else {
  State.variables.slotA = false;
}
<</script>>

<<if $slotA is true>>
  The first game slot exists! (This session was most likely reloaded from a game save.)
<</if>>

<<link "Save to the first slot?">>
  <<script>>
    if (Save.slots.ok()) {
      Save.slots.save(0);
    }
  <</script>>
<</link>>

<<link "Load from the first slot?">>
  <<script>>
    if (Save.slots.has(0)) {
      Save.slots.load(0);
    }
  <</script>>
<</link>>

<<link "Delete first slot and restart story?">>
  <<script>>
    if (Save.slots.has(0)) {
      Save.slots.delete(0);
      Engine.restart();
    }
  <</script>>
<</link>>

This works perfectly fine. Problem is, it’s bound to one specific passage.
What I’m trying to figure out is if it’s possible to have it be available in every single passage. I tried directly writing to JavaScript, but to no avail.

To give sort of an idea of what I’m trying to achieve, this is what I’m trying to get to work.


With the Save menu on the bottom using the functions of Sugarcube.

If anyone would be able to help, I’d be incredibly grateful.

Thanks in advance!

1 Like

I’m just learning Sugarcube, but I believe there’s a “footer” passage type that will add the contents to every page viewed by the player.

Just looked it up, and this may be out of date, but try using a passage called “PassageFooter”…I’ll get yelled at I’m sure if I’m giving you outdated links, but here:

https://twinery.org/cookbook/headersandfooters/sugarcube/sugarcube_headersandfooters.html

That’s still the one.

https://www.motoslave.net/sugarcube/2/docs/#special-passage-passagefooter

1 Like

Yeah… Completely ganced over those notes on the Cookbook and other places… Thank you so much for the help on this, everyone! I was almost ready to start pulling my hair on this…