Noob question, reusing code with label

Very noob here, trying out a proof of concept. Is there a way to reuse this code/sentences, or at least do it in a way that I don’t have to type it multiple times? When I try using *label above those two lines, it still takes me to the French name choices when I select the Germany option. What am I doing wrong? How can I “close” the label tag?

*label pc_nationality_options
*choice
	#France
		*set pc_country "France"
		*label newname
		You come from ${pc_country}
		The officer looks at you. "Last name?"
		*goto pc_name_French
	#Germany
		*set pc_country "Germany"
		*goto label newname
		*goto pc_name_German

Thanks!

You can use the *gosub command here. More info on this wiki;

You can use the *goto command to move to another label. You can check this page here;

Hope this helps!

2 Likes

I’m pretty new myself, but in your example, it seems you’ve placed the *label newname tag under the ‘France’ choice (just below *set pc_country “France”) and under your ‘Germany’ option, you’ve placed a *goto label newname command instead of a *label newname tag, which will take you to the ‘France’ portion.

1 Like

Hi, is this was you’re trying to do?

I have Implicit Control Flow turned on; if you don’t, you would need to add *goto after *if and *elseif

2 Likes

Quick note: *label pairs with a *goto of the same name.

Take a closer look. Under your #Germany choice option, you have *goto label newname. 1) this is an invalid snippet; correct one would be *goto newname, 2) see where is your newname goes.

Spoiler
*label pc_nationality_options
*choice
	#France
		*set pc_country "France"
		*goto newname
	#Germany
		*set pc_country "Germany"
		*goto newname

*label newname
You hail from ${pc_country}.
[n/]The officer looks at you. "Last name?"
*if pc_country = "France"
	*goto pc_name_French
*elseif pc_country = "Germany"
	*goto pc_name_German
1 Like

Question, isn’t *gosub for when the code contains commands, not for when it’s text?

I see. So it’s better to use if commands here for the list of name choices, rather than what I’ve been doing?

There’s no difference. When you’re writing plain text, behind the scenes it’s basically a “command” that prints text to the screen.

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the @moderators.