0 votes
by (120 points)
I am trying to make a checkpoint system in my game but I am having some issues with it. Basically I want to have a link that says Return to Previous Checkpoint, and I want it to lead to different passages based on player choice, I am a bit unsure of how to do this exactly. Thank you.

1 Answer

0 votes
by (156k points)

Please use the Question Tags to state the name and full version number of the Story Format you are using, as answers can vary based on this information.

The following examples will assume you are using the default story format which us currently Harlowe v3.0.2 however the techniques described below will also work with SugarCube 2.x, but you will obviously need to change the code.

The three simplest ways to do what you want are listed below, the first two assume you are using story variables to track the choices made by the player. eg. $choice1 contains the first choice made.

1. Use (if:) related macros to conditionally show the correct link.

(if: $choice1 is "some value")[
	[[Click here->Next Passage A]]
(else-if: $choice1 is "some other value")[
	[[Click here->Next Passage B]]
	[[Click here->Next Passage C]]

2. Use (if:) related macros to assign the name of the target passage to a variable, and use that variable when showing the link.

(set: $targetPassage to "Next Passage C")
(if: $choice1 is "some value")[
	(set: $targetPassage to "Next Passage A")
(else-if: $choice1 is "some other value")[
	(set: $targetPassage to "Next Passage B")
(link-goto: "Click here", $targetPassage)

3. Determine the target passage name at the point the player makes the choice, so in this case the $choice1 variable contains the passage name and not the choice made.

Make a choice:
(link-reveal-goto: "Option 1", "Some other passage")[
	(set: $choice1 to "Next Passage A")
(link-reveal-goto: "Option 2", "Some other passage")[
	(set: $choice1 to "Next Passage B")
(link-reveal-goto: "Option 3", "Some other passage")[
	(set: $choice1 to "Next Passage C")

... and then use the current value of the $choice1 variable when later showing the link you want to conditionally target different passages.

(link-goto: "Click here", $choice1)


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.