Default name and sexuality bug(?)

Twine Version: sugarcube 2.34.1

I had a question, and I wasn’t sure if it had been asked already. I used the Topic: Default name doesn’t work (by C.Johnny), and it hasn’t elaborated any further than where it finished (makes sense, doesn’t it?). My problem is that I used:

<<link “I like girls.” “Next Passage”>>
<<if $name === “Cloud”>>
<<set $sex = “straight”>>
<>
<<set $sex = “lesbian”>>
<>
<>
<<link “I like boys.” “Next Passage”>>
<<if $name === “Cloud”>>
<<set $sex = “gay”>>
<>
<<set $sex = “straight”>>
<>
<>
<<link “I don’t.” “Next Passage”>>
<<if $name === “Cloud”>>
<<set $sex = “aromantic”>>
<>
<>

And, when I used it in the beginning, I was able to continue. Until I got to the passage “Park the bike and go inside”, which is where the player sees either a girl, boy, or not (last is aromantic). And what’s supposed to happen is that the player sees one of them based on which choice they picked in the beginning:
“I like girls.”
“I like boys.”
“I don’t.”

So, if the player chose their gender to be “male”, their name is “Cloud” and would then choose if they like girls or boys or neither. And if the player is “male” and chooses “I like girls.”, then at the “Park the bike and go inside” passage, they wouldn’t see:
“As you park your bike once you get there, you see someone. You see a…
girl
boy
I don’t see anyone”, and, instead, they would just see “girl”. I’m not sure if I’m explaining this well enough, but I’m stumped here and don’t know how to fix it. After, they’re supposed to talk to the person, and go on a possible romance route. If they don’t see anyone, then it just says that they go inside the convenience store (that’s the “inside” when talking about going inside, just wanted to say that). This is a horror/romance novel, and it’s supposed to be absurd with two totally different genres. The aromantic route is for the horror part only, and I want to keep up with that, as well.

The error I get when testing it:
"Apologies! An error has occurred. You may be able to continue, but some parts may not work properly.

Error: cannot find a closing tag for macro <>.

Stack Trace:
Error: cannot find a closing tag for macro <> at Function.value (:6:21158)
at HTMLAnchorElement. (:8:17076)
at HTMLAnchorElement. (:7:30953)
at HTMLAnchorElement. (:4:4789)
at HTMLAnchorElement. (:4:4565)
at HTMLAnchorElement. (:23:43090)
at HTMLAnchorElement. (:23:41074)"
And I can’t get any farther. I’m working on the script so I have somewhere to go after all of it is fixed, but, at this point, I can’t get any farther with that particular part in the game.

For anyone willing or able to help, it would be highly appreciated! Sorry if there are any mistakes or I need to clarify something, if it’s needed, I can try to give a longer explanation if there’s something that’s unclear. Thanks in advance to anyone that helps! Also, sorry if some of the text isn’t visible, this is the first post I’m making and am a very new user, lol.

Yeah, you’ll want to select the code bits and use the Preformatted Text (</>) button, as otherwise the forum display eats some of it. :frowning:

If I’ve guessed correctly your original code example looked something like…

<<link "I like girls." "Next Passage">>
	<<if $name is "Cloud">>
		<<set $sex to "straight">>
	<<else>>
		<<set $sex to "lesbian">>
	<</if>>
<</link>>
<<link "I like boys." "Next Passage">>
	<<if $name is "Cloud">>
		<<set $sex to "gay">>
	<<else>>
		<<set $sex = "straight">>
	<</if>>
<</link>>
<<link "I don’t." "Next Passage">>
	<<if $name is "Cloud">>
		<<set $sex to "aromantic">>
	<</if>>
	/* What does $sex equal when name isn't Cloud? */
<</link>>

And if I assumed that your $name and $gender variables had values like the following…

/* Assign a default value to name and gender for debugging purposes. */
<<set $name to "Cloud", $gender to "female">>

And if I understood correctly the condition needed for the statement to be shown, then I believe the following is what you need…

debugging: Name: $name; Gender: $gender; Sex: $sex

<<if $gender isnot "male" and $sex is "straight">>
	"As you park your bike once you get there, you see someone. You see a… girl"
<</if>>

Thank you! I’m having a difficult time understanding everything, though. For the first passage, it’s the “Start” passage, and the following text is displayed:
[[I am male.|Who do I like?][set $name to “Cloud”, $gender to “male”]]

[[I am female.|Who do I like?][set $name to “Sky”, $gender to “female”]]

The “set $name to ‘Cloud’, $gender to ‘male’” (as well as the one for “Sky”) was changed from the original, which I added from your reply. However, I’m getting a new error. The error is an “Unexpected identifier”. I can’t move past the start passage, and am now unable to get to the passage about parking the bike. I’m also entirely unsure if this will even be sent because I can’t access the topic for some reason (it’s blocked, I believe), but it said I could reply to the email to send a reply so I’m hoping that this can be shown at all.

I’ve changed the code to:
[[I am male.|Who do I like?][set $name to “Cloud”, set $gender to “male”]]

[[I am female.|Who do I like?][set $name to “Sky”, set $gender to “female”]]

and:
[[I am male.|Who do I like?][set $name to “Cloud” set $gender to “male”]]

[[I am female.|Who do I like?][set $name to “Sky” set $gender to “female”]]

(the second is without the commas) And I’m getting the same error. I’m really sorry if this isn’t enough information, I’m not sure if I’m putting it down correctly. I can try to give more information about it if necessary. Thank you for your help!

Please use code blocks for code (looks like </> on the editor bar).

The link markup setter component does not use set. For example:

[[I am male.|Who do I like?][$name to "Cloud", $gender to "male"]]

[[I am female.|Who do I like?][$name to "Sky", $gender to "female"]]
1 Like

It may want semi-colons, rather than commas. It almost certainly does not want “set” a second time, as you later tried. My experience is mostly with Twine 1, but I would expect this to work:

[[I am female.|Who do I like?][set $name to “Sky”; $gender to “female”]]

Nope. The “set” shouldn’t be in there at all, and it should be separated by commas, not semicolons.

See the post above yours, which is by the author of the SugarCube story format.