Hide a different Link until one of three Link-Replaces clicked

I am working in Twine 2.8.1 and Harlowe 3.3.8

I have a section where I offer the player 3 choices and then when one is chosen they all disappear and are replaced by the text for the clicked link. General example of the code below;

[
(link-replace:"link1")[(replace:?namedHook1)[replaceText1.]]
(link-replace:"link2")[(replace:?namedHook1)[replaceText2.]]
(link-replace:"link3")[(replace:?namedHook1)[replaceText3.]]
]<namedHook1|

The issue I have is that I want a link to a new passage to show up after the replaced text, but not be there before when the player is choosing between the 3 choices. I know I could simply put the link at the end of all 3 replaceTexts, or set a variable in each replaceText that the final link checks for (with an if or unless) before it appears.
I don’t like the duplication and worry about needing to change the code in multiple places if I change anything. Is there a way to have a link only show up when “namedHook1” is gone/replaced? Or that will only show up after either link 1, 2 or 3 have been clicked?
Thanks for any advice you can provide.

1 Like

You could store the link in a variable that you set in a Startup passage:

(set: $link to "<br>(link-goto: 'Next passage link', 'passagename')")

And then:

[
(link-replace:"link1")[(replace:?namedHook1)[replaceText1. $link]]
(link-replace:"link2")[(replace:?namedHook1)[replaceText2. $link]]
(link-replace:"link3")[(replace:?namedHook1)[replaceText3. $link]]
]<namedHook1|

In this situation, I would use a Hidden Hook to “hide” the 4th link, and the (show:) macro to later “reveal” that 4th link.

[
(link: "link1")[(replace:?namedHook1)[replaceText1. (show: ?4thlink)]]
(link: "link2")[(replace:?namedHook1)[replaceText2. (show: ?4thlink)]]
(link: "link3")[(replace:?namedHook1)[replaceText3. (show: ?4thlink)]]
]<namedHook1|
|4thlink)[ [[Label->Target Passage]]]

note: You don’t need to use the (link-replace:) macro, because you’re replacing the entire contents of the Named Hook those “links” are positioned in.

Thanks for the suggestions, but these are the kind of things I was talking about when I mentioned duplication. I know I can accomplish what I want by putting the same thing at the end of the 3 links (and that’s what I’ll do if there isn’t another way to do it).
I’m specifically asking for a way to keep my code as clean as possible without unnecessary duplication. So instead of having $link or (show: ?link) repeated in all 3 options, I’m trying to see if there’s a way to have a single thing after the 3 that makes the link appear only after one of the 3 is chosen.

There’s three spots you can click so you need three commands. The best you can achieve is to get these commands to point to the same thing.

Thank you for clarification. I really felt there would be some macro or combination of macros that would basically be able to go “if any 1 of these 3 is clicked, then do X”. I guess I will resort to just putting something in each of the 3 hooks to trigger the thing to show.
Thanks again :+1: