How to change the links based on random print text?

Latest update of Twine with Sugarcube

So I want to have different links show up based on what random text is printed using <<print either(“”)>>. I’m figuring there’s probably something not quite clicking in my code or there maybe a macro I need to get my hands on. If anybody has suggestions I’m all ears.

Here’s what I have so far:

Hello <<print either ("sir", $name)>>, I need you to do something for me.

I need you to <<print either ("remove someone", "save someone")>>, tonight, if you can help it.

<<if print is "remove someone">>
[[Yes Sir]] 
<<elseif print is "save someone">>
[[Yes sir]]
<</if>>
[[No sir]]

Apparently capitalization matters so I was able to squeak that by, similar but distinct enough for the program. Any suggestions welcomed, macros included!

Hiya :slight_smile:
You might want to take a look at the official documentation for how macros work.
Unfortunately it is not possible to have a conditional statement to check whether a random bit of text is printed.
What you could so is

<<set _temp to either("remove someone", "save someone")>>
Your sentence ...  <<print _temp>>....

<<if _temp is "remove someone">>
Your link....
<</if>>

2 Likes

In addition to what Manon said, you should take another look at the link markup documentation—the link text doesn’t actually have to be the title of the target passage. The simplest possible link markup is [[Passage title]], yes, but you can also write [[Link text|Passage title]], and “Link text” is what will display. So you could have, e.g., [[Yes sir|remove]] for your first link and [[Yes sir|save]] for your second, and they would go different places and there would be no issue with the displayed text being identical.

4 Likes

Thank you @manonamora ! That did it! I really appreciate the help! And @EJoyce , thank you for the help as well, that’ll make my passage making a lot clearer. I’ll try and absorb the documentation stuff, though I might need to find a tutorial for it to stick lol

2 Likes