Help with Bolean Variables

Twine Version: 2.3.12
Story Format: Sugarcube 2.34.1

Hello all,

I’m trying to learn how to use bolean variables. Right now I’m trying to use it to introduce new characters in the game.
In my StoryInit I have a bolean variable
<set $meetmayor to false>
In the StoryMenu under a menu called Journal I want to have NPC profiles written and when the variable is set to true in game the link is available. I wrote in this syntax
<<if $meetmayor to true>>[[Village Mayor]]<>
In one of my passages I wrote a link passage with a bolean variable in it.
[[You secure the village and meet the Mayor.|Page 3][set $meetmayor to true]]

None of it works. Right now I get in my Journal Menu this is displaying
Error: <>: assignment operator found within <> clause (perhaps you meant to use an equality operator: ==, ===, eq, is), invalid: $meetmayor to true

In the passage the link gives me a syntaxerror: Unexpected Identifier.

What am I doing wrong?


Just like the error message says, when you check the state of a variable, you don’t use “to”. The code should be <<if $meetmayor is true>> or just <<if $meetmayor>> (this also checks to see if the variable in question is true).

Also, you shouldn’t use “set” when setting variables using links like in your example. The correct version of that link would be

[[You secure the village and meet the Mayor.|Page 3][$meetmayor to true]]

1 Like

TY! This helped me out tremendously. I still have a lot to learn.

1 Like