Struggling with Name Input

I’ll try to type a step by step explanation of what you have to code for this.

First off, in your opening post, you wrote code like this
*create_player 0
input_text_player_name
*set player_name “{player_name}”

You have to be careful with the underscore _. I don’t know if you actually coded it like that in CS IDE, but you should only use an underscore when either
a) the code-command demands it, like *input_text or *page_break or *line_break
b) you want to create a multi-word variable and thus needs to connect those words.

The code recognizes the command [*create]. The first word after the space following the code will be recognized as the name of the variable you created. The third word will be tried to be read as the value of the variable, but you have to put text values in " " to be registered properly. If you want to use multiple words for your variable, like [player_name], then it needs an underscore to connect the words and be recognized as the variable. You could also shorten this to e.g. [pname].

Next, [*input_text] is a command and thus needs the asterix * to be recognized as such by the script. After the command follows a space. The word that follows now has to be an already existing variable. So the variable [player_name] has to be created already! You need to [*create player_name “”] in the startup.txt before you can use [*input_text player_name]. This variable will be set to whatever the player then inputs. Thus you do not need an additional line [*set player_name “{player_name}”] because [player_name] was automatically set to whatever the user wrote into the [*input_text].

What you’re actually doing when writing [*set player_name “{player_name}”] is setting the variable [player_name] to the value [{player_name}] <<<— this will be the text output whenever you write [${player_name}], not whatever the user put into [*input_text] before. You are overwriting that input with the value {player_name}.

Now an attempt to an explanation using Jumo's code example as a base
*create fname "" (these two variables work as firstname and lastname. You can write whatever here as long as you know what the purpose of the variable is)
*create lname ""

*label name (I gave the name-setting-section its own label so that I can later return here if the player wants to redo their name. Check the choice following afterwards)
First name? (asking for the first name so the player knows what variable we're going to set now)
*input_text fname (there's first the command *input_text, then the name of the variable. You don't need any additional *set xxx "y" because this command does that for you already. Make sure that the variable you write after *input_text was already *created (to be used in multiple chapters) or a *temp (to be used only in one chapter. If the name of your variable is [player_name], then write *input_text player_name instead.)
Last name?
*input_text lname

So your name is ${fname} ${lname}? (The player can now check if their input was correct. If you write $!{fname} (note the exclamation mark ! here), then the first letter of the input will be capitalized in case it had been as smallcase letter. The player can then choose "Yes, continue" or "No, let me do it again")
*choice
	#Yes, it is!
		*goto next_label
	#No, it is not. Let me change that.
		*goto name

*label next_label
Continuing here if the player was happy with their input. The name of the label can be whatever you want it to be. This is just an example.

The tl;dr: What others have said already. You have to create the variable you want to use for *input_text first before you can set it to anything using *input_text. Also, you do not need an additional *set xxx y to actually set the variable to the input_text, because *input_text automatically does that for you.

3 Likes

A bit late to the party but here’s why:

In order to represent the value assigned to a variable in text (in this case, fname and sname’s values being the name the player puts it) you need to show them as ${variablename}, and make sure the variable names match (actually I am not sure if the capitalization has anything to do with it. Just pointing out that in the image above, they are fname and sname while in the stats screen, they are Sname and Fname)

So in short, just add a $ before the { symbol. This applies to every variable including numbers and text. This does not apply to start charts though.