Default name doesn’t work

I am using Sugarcube 2.30.0 in Twine 2.3.5. I need some help regarding default names for my story.

The player has the option to be male or female and the names will default to their corresponding gender.

<<choice “I am female.”>><<set $name = “Jill”>>
<<choice “I am male.”>><<set $name = “John”>>

Yet when I tested my game, it just used the default name “John” when I clearly chose the female option. What did I do wrong?

The <<choice>> macro doesn’t work like that (and, honestly, you’ll probably never need that macro).

A much simpler way to make that work would be to do:

[[I am female.|Passage Name][$name = "Jill"]]
[[I am male.|Passage Name][$name = "John"]]

Just substitute “Passage Name” for the name of the passage you want it to go to when you click that link.

Hope that helps! :smiley:

2 Likes

Thank you so much! I also need help with another thing. Since my story is romance based, I want the players to be able to choose who they’re attracted to. This is the code I used:
<<choice “I like girls.”>><<if $name === “John”>><<set $sex = “straight”>>
<<elseif $name === “Jill”>><<set $sex = “lesbian”>>
<>
<<choice “I like boys.”>><<if $name === “John”>><<set $sex = “gay”>>
<<elseif $name === “Jill”>><<set $sex = “straight”>>
<>

I want to make the story feel more organic to the choices the player makes. Basically, I want the players to read certain scenes only if they have a specific item or a specific gender and sexuality.

1 Like

You can use the <<link>> macro for that:

<<link "I like girls." "Next Passage">>
	<<if $name === "John">>
		<<set $sex = "straight">>
	<<else>>
		<<set $sex = "lesbian">>
	<</if>>
<</link>>
<<link "I like boys." "Next Passage">>
	<<if $name === "John">>
		<<set $sex = "gay">>
	<<else>>
		<<set $sex = "straight">>
	<</if>>
<</link>>

Just change “Next Passage” to the name of the next passage to go to.

Enjoy! :smiley:

P.S. In this forum you’ll need to put any code inside “preformatted text” markers (using the </> button), otherwise it tends to eat macros.

3 Likes

It worked perfectly! Thanks so much! :smiley: