0 votes
by (130 points)

I'm new to this kind of stuff, so this may be a very easy solution that I'm just missing, so bear with me please! I'm wanting to have a gender selection screen towards the beginning of my story. I'm using Harlowe 2.1.0 and Twine2. I've googled this and found a code that I thought would work, but unfortunately, when you go from the first passage to the second it will always only give one response, regardless of what gender you picked. These are my passages with codes. 

"Are you a boy or girl?"

[[Male->Mirror]](set: $gender to "male")
[[Female->Mirror]](set: $gender to "female")
(if: $gender is "male")[
You stare at your masculine reflection.
]
(else:)[
You stare at your feminine reflection.
]

With this one, even if you click "male" the second box will talk about your feminine reflection, which is the female response. When testing, it also only says there is one variable, the string "female". Any help would be greatly appreciated! Thanks!

1 Answer

+2 votes
by (63.1k points)

If you need a link to run some code, you have to use the (link:) macro. 

(link: "Male")[\
    (set: $gender to "male")\
    (goto: "Mirror")\
]
(link: "Female")[\
    (set: $gender to "female")\
    (goto: "Mirror")\
]

The way you have it set up, clicking the links does nothing (other than forwarding to the "Mirror" passage), and the $gender variable is set to "male" and then "female", always. So on the next passage or in later code, the value will always be "female". 

by (130 points)
Thank you! I really appreciate your help.
...