0 votes
by (180 points)
retagged by

I'm using Harlowe 1.2.4

I want to reveal text and a link in one passage only if the reader visits 3 other passages. Basically, a reader reads passage A, gets access to passages B, C and D. The reader goes through all of them and returns to passage A. I want IF macro to check if the reader has visited B, C and D and then produce new text and link on passage A.

I tried using AND in the IF macro to check for all three conditions, but that didn't work. Below is what I used:

(if: $Lib040A is true and $Lib040B is true and $Lib040C is true)[
Access granted to new files.

Would you like to access this library?


[[*Yes*->050]]

]

 

Thanks!

1 Answer

+1 vote
by (1.6k points)
selected by
 
Best answer

Someone may have a suggestion for an improved way to handle your scenario, but isolating the conditions within their own brackets should get your example working:

(if: ($Lib040A is true) and ($Lib040B is true) and ($Lib040C is true))[
       Access Granted
]

 

by (180 points)
That did the job, thanks!
by (149k points)

You shouldn't be using either is true or is false when testing if a story variable equals Boolean true or false.

The correct way to test for Boolean true and false is

(set: $variable to true)
(if: $variable)[The story variable equals Boolean true]

(set: $variable to false)
(if: not $variable)[The story variable equals Boolean false]

... so geekdragon's suggestion should be.

(if: $Lib040A and $Lib040B and $Lib040C)[
       Access Granted
]

 

by (1.6k points)
Whoops! Thanks for setting things straight greyelf. I have a bad habit of using other data types where booleans are appropriate, so I missed the obvious issue.
by (180 points)
geekdragon's method seems to be working for me without any trouble. But greyelf's method returns by saying that it can only use 'and' with booleans.
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.
...