+1 vote
by (940 points)

Hello everyone, now I was building the save system and for the most part works without problems, it saves and loads correctly.  This is the code I'm using:

 

{
<!--Asks for name of the save, then saves, checks if it worked and reloads the passage to update the save name-->
(link-repeat: "Save")[
(set: $Slot1Name to (prompt: "Name your save file", "Slot 1"))
(if:(save-game: "Slot1", $Slot1Name))[(alert: "Save successful!")]
(go-to: "SaveManagement")]

<!--Displays the save name-->
(if: (saved-games:) contains "Slot1")[Slot empty]
(else:)[(print: (saved-games:)'s "Slot1")]

<!--Checks if save game exists, then loads and jumps to the last story passage-->
(link-repeat: "Load")[(if:(saved-games:) contains "Slot1")[(load-game:"Slot1")
(go-to: $lastVisitedStoryPassage)]
(else:)[(alert: "No save found!")]]
}

The idea is to have on a line: 

[Save] Savename [Load]

 

But it appears both go-to macros do not work as the name is not updated and the passage is not changed when loaded. I really don't understand why.

1 Answer

+2 votes
by (158k points)

You have the logic of the code that displays the slot's name around the wrong way, you're displaying Slot empty when the slot exists and trying to display it's name when it doesn't.

Try the following:

<!--Displays the save name-->
(if: (saved-games:) contains "Slot1")[(print: (saved-games:)'s "Slot1")]
(else:)[Slot empty]

 

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...