0 votes
by (160 points)

Hello everyone. I have a passage that is the following:

You fill your lungs with fresh air and feel air rush in for the first time. Everything around you seems to be a blur and sounds mix and morph together. Amidst a muffled and distorted soundscape you can make out your mother’s voice. You instinctively recognize her smile and eyes. You hear a lower rumble, this must be your father’s voice. Not knowing what the world holds for you in this moment you are comforted by the presence of your new parents and a warm blanket wrapped around you.

[[You are a baby boy and your parents name you Oren->Oren1]]

[[You are a baby girl and your parents name you Serena->Serena1]]

However, what I really want to do is for the first link to set the variable $sex to "female" and the second link to set the variable $sex to "male". Then I would like both links to go to the same next passage instead of Oren1 and Serena2. In the next passage I want to generate the text using (if: $sex is "female)[female specific passage contents] and (if: $sex is "male")[male specific passage contents]. Any ideas on how to do this? It seems I'm not able to set a variable when a link is clicked.

Thank you for any help.

1 Answer

+2 votes
by (560 points)
edited by

However, what I really want to do is for the first link to set the variable $sex to "female" and the second link to set the variable $sex to "male".

I'm going to assume this is a typo and you want it the other way around. Here's what I would do,

(link: "You are a baby boy and your parents name you Oren.")[
	(set: $sex to "male")
	(go-to: "Next Passage")
]
(link: "You are a baby girl and your parents name you Serena.")[
	(set: $sex to "female")
	(go-to: "Next Passage")
]

You don't really need to use both (if: $sex is "male) and (if: $sex is "female"); an if-else statement would be more suitable. Let's say you set male to be the default gender in your startup passage. Then you could do something like this,

(if: $sex is "male")[You walk into the male bathroom.](else:)[You walk into the female bathroom.]

Obviously you can do this the other way around and set female to be the default if you wish.

by (160 points)
Thank you so much for the help! And yes you were right it was a typo.
...