Hiding passage links based on variables? (Harlowe 2.1) Please help!

0 votes
asked Apr 17 by zoealyse (170 points)

hi all! i'm new to twine and have been looking through this manual for help, but i'm still a little lost. here's my deal:

i have a story and i'm implementing some variables (example: if you decide to pick up an object, i have either (set: $Item to false) or (set: $Item to true), and they print properly if i call them later). i wanted to know if it's possible if, based on whether or not this is true or false, i can hide/show a link to another passage (so, if the player has the item, an extra passage link is available to click. if not, they just have one choice).

i know there are (if:) and (hidden:) macros, but i'm a) not sure if that's what i want, and b) not sure how to make them work because i've already tried implementing them anyway and just got errors haha.

any help would be much appreciated!

1 Answer

+1 vote
answered Apr 17 by greyelf (91,050 points)

You can use the (if:) macro to do what you want.

[[Always shown->Next Passage]]

(if: $Item)[ [[Only shown if Item variable is true->Next Passage]]]

(if: not $Item)[ [[Only shown if Item variable is false->Next Passage]]]

 

commented Apr 17 by zoealyse (170 points)

hi! thank you for responding. this is what i made my code look like:

[[Always shown->Continue.->Three out of Five]]

(if: $Weight)[ [[Only shown if Item variable is true->Give Avery the paperweight.]]]

(if: not $Weight)[ [[Only shown if Item variable is false->Continue.->Three out of Five]]]

but it appears like this: https://imgur.com/a/Kcdil

did i mess something up? i want the "continue." option to always be there, but the "give avery the paperweight" only appears if $Weight is true.

commented Apr 17 by zoealyse (170 points)
ah, nevermind, i was able to solve it! thanks again :)
commented Apr 17 by greyelf (91,050 points)

@zoealyse I'm gad you were able to solve that yourself.

For anyone else wondering why the markup based links appeared incorrectly, the reason is because zoealyse accidentally forgot to replace the Link Text used in my examples with their own. They also didn't need to include the (if: not $Weight) example because that use-case was covered by the first (non-conditional) markup based link.

eg. The final Passage should of looked something like.

[[Continue.->Three out of Five]]

(if: $Weight)[ [[Give Avery the paperweight.]]]

... assuming that the Link Text and the Target Passage Name are the same for the conditional markup based link.

commented Apr 17 by zoealyse (170 points)

hey, so i actually have a follow up question if you don't mind!! i applied this same method to just text instead of passage links but it kind of causes a formatting issue. 

this is the code (sorry for the story elements haha i'm not sure what would be a better way to communicate the problem):

A while later, Violetta steps out of Room 268 and joins Tess & Avery down the hall. She gives a friendly wave to Avery and leans back against the wall.

(if: $A > 1)[''"Hey, lovebirds. Have either of you heard from Laura or Thaddeus lately?"''

Avery faintly blushes as Tess shakes her head. ''"No, is something up?"'']

(if: $A <= 1)[''"Hey, you too. Have either of you heard from Laura or Thaddeus lately?"''

Tess shakes her head. ''"No, is something up?"'']

but it looks like this - note the awkward gap between the first and second paragraph compared to the rest. i get that it's ignoring the first if statement because it's not true, but is there a way to get rid of that gap in the html? sorry for the bother!!

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.
...