Hiding a button until certain criteria is met

Twine Version: 2
[also choose a Story Format tag above]

I have searched all over the place for the answer and cannot seem to find it. I created a fast travel system. where you click a button on the sidebar and there are buttons for each area. I just want to make the fast travel button on the sidebar to be invisible or at least unable to be used until the player reaches the sandbox portion of the game.

Is it possible to use if-statements in the sidebar passage? If so, it seems you could read the current passage name and hide the button based on that? It might depend on when the sidebar renders.

1 Like

You can add a “hidden” class (styled with display: none) to the element, and toggle it when you need it

1 Like

Yup either through a variable or a hasVisited function:

:: StoryCaption
<<if $var is true>>
    [[Text|Link to Passage]]
<</if>>
<<if hasVisited("PassageName")>>
    [[Text|Link to Passage]]
<</if>>

Ok cool. Ill give this a try and see what i can do with it thanks!

Are there any automatic system variables? I expect it varies by flavor of Twine. AXMA had system variables which you could use in statements - $$passage was the current passage and $$from was the name of the previous passage the player just saw, which does not sound like much but is shockingly useful for varying text.

<<if $$from eq 'Rocky Cliff'>>
Ouch! That tumble down the cliff hurt a lot!
<<endif>>
You are on the beach near some dangerous cliffs.

$$fromprevious()
$$passagepassage()
(with those you can check the name of the previous or current passage)

<<if previous() is "Passage">>
<<elseif passage() is "Name">>
<</if>>

Note: this is only for SugarCube2

1 Like

These were perfect thank you for the help