Trouble with naming code

I’m having trouble with this code of mine. I tried copying the way “Choice of Dragon” did this section, but somewhere I went wrong. I’m at the naming section of my script and it works as planned with the names I inputted, but it doesn’t work with the entered name. It lets the player input their name as normal, but then it goes straight to the end as if I put the command *finish.

My code looks like this:
*choice
#Adam
*set name “Adam”
*goto gender
#Alexandria
*set name “Alexandria”
*goto gender
#Claire
*set name “Claire”
*goto gender
#Damien
*set name “Damien”
*goto gender
#Levi
*set name “Levi”
*goto gender
#Robin
*set name “Robin”
*goto gender
#I’d like to input my own name…
Oh! Of course.
*label input_name
What is your name?
*input_text name

     *if ("${name}" != "$!{name}")
         
         Your name is $!{name}, is that right?
          *choice
             #Yes
                 *set name "$!{name}"
                 *goto gender
             #No
                 *goto input_name
                 *goto gender

What does the code do when the inserted name is already capitalized? I don’t see that bit of code here.

It’s probably falling out of a choice or if-statement somewhere. (Like, taking a wrong turn because the signpost telling the code where to go is missing or not in the right spot.)

I think its because of the *if (“${name}” != “$!{name}”) since that line will always return false and thus the code inside it will never run.

Essentially, if the name the player inputs is “Richard”, that if statement would be checking "if “Richard” doesn’t equal “Richard” then run the code.

Can I ask what the purpose of that if statement is? It doesn’t seem to be used for anything.

I honestly don’t know, I was trying to focus on copying how Choice of Dragons did it, but I think I copied it a bit too literally. Thank you for your answer!

It seems to be checking if the input is capitalized and capitalizing the name if it isn’t already.

also pinging @Alex1897 since this might be relevant

choicescript isn’t case sensitive, if you want a variable to be printed as they input it, you would use ${name}, if you want to print it with the first letter capitalized, you can use $!{name} and it will automatically capitalize the first letter of the string value.

The if statement is just checking if whatever the input value is equals itself.

To add onto this, if you wanted to set the input to the capitalized value you could use
*set name "$!{name}"

1 Like

Tell me if this code does what you are looking for.

*fake_choice
	#Adam
		*set name "Adam"
		*goto gender
	#Alexandria
		*set name "Alexandria"
		*goto gender
	#Claire
		*set name "Claire"
		*goto gender
	#Damien
		*set name "Damien"
		*goto gender
	#Levi
		*set name "Levi"
		*goto gender
	#Robin
		*set name "Robin"
		*goto gender
	#I’d like to input my own name…
		Oh! Of course.
		*label input_name
		What is your name?
		*input_text name
Your name is $!{name}, is that right?
*fake_choice
	#Yes
		*set name $!{name}
		*goto gender
	#No
		*goto input_name

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