Help with variables and hidden passage links in Twine/Harlowe

What I’m trying to do: Reveal additional passage links based on passages the player has visited. For example, visiting one Passage should “unlock” a link to another passage in the “Downtown” passage.

How I’m trying to do it: Set a variable to true when they visit a passage that should unlock another passage. On the “Downtown” page, I’m just using if: and hidden hooks. Example: (if: $megansapartment is true)[ [[Old Salty's]]])

The problem: Navigating to the Downtown passage using the back arrow icon doesn’t re-run the if: macro (based on https://twine2.neocities.org/#macro_if this appears to be by design).

I can get it to work by adding a link back to Downtown from Megan’s Apartment, which apparently does re-run the macro. So I guess I could try to just remove the back and forward arrows from the template and only use hand coded passage links for navigation, but I’m hoping there’s a better way to do what I’m trying to do (it’s also not clear to me that my workaround is officially supported, so I’m worried it might break at some point).

Thanks in advance!

That is by design. Using the “back” arrow resets the state of the story to its last previous point. It’s not re-running the passage, it is literally rewinding the story’s values.

Having explicit links would help in this regard. Clicking on a link is considered a “turn” and the story’s values are updated as a result.


Depending on how you have designed your story, looking at (history:) may help, too. You can test to see if the player has visited certain passages previously.

Using is true or is false when evaluating the current state of a Boolean variable is redundant, and results in that evaluation taking more steps / longer to achieve the same outcome.

The correct ways to check if a Boolean variable is currently true or false using the (if:) or (else-if:) macros are:

(if: $variable)[The variable currently equals true]

(if: not $variable)[The variable currently equals false] 

Thank you both!

If I just use (if: $variable) I get the error “(if:)'s 1st value is the number 0, but should be a boolean.” (I think this is why I did it the way I did it before in the first place, come to think of it).

Harlowe automatically assigns a default value of 0 (zero) to any variable that is referenced that hasn’t previously been assigned a value by you. Unfortunately (unlike most programming languages) Harlowe doesn’t consider a numerical value (like 0 or 1) as the equivalent of a Falsy or Truthy value.

If you are going to use a variable as a Boolean then you need to initialise it to either true or false before hand, often this is done within your project’s startup tagged special passage.

eg. sometime prior to your evaluating of the current value of $variable you need to do one of the following:

(set: $variable to true)

(set: $variable to false)