Need help in code looping?

hello, I’m looking for help on how to “loop”(?) my choice back to the first bit.

I want to allow players to choose their own name and I found the command to use the little text box. but what if they misspell or mistype and wish to correct it. how do I loop the text back to let them fix it?

What is your first name? 
*input_text name

You name is ${name}, correct? 
*choice 
#That is correct. 
*finish

#No, I wish to change it.

You need to label the initial choice of name. For example:

*label inputname
What is your first name? 
*input_text name

You name is ${name}, correct? 
*choice 
    #That is correct. 
        *finish
    #No, I wish to change it.
        *goto inputname

Also, make sure each choice is indented properly.

1 Like

yes, I have the proper indents on my computer, I’m writing this on my phone, sorry the indents weren’t shown here.

I now have an error for “non existent variable”, how do I add the name command to the startup and what should it look like?

Since you wrote name in *input_text, you should do it like this:

*create name "Unknown"

EDIT:

Unfortunately no, I don’t know which WIP you’re referring to :sweat_smile:

But yes, it should use the same *create command, just with a different name for the variable (“parent_firstname” instead of “name”). If you have multiple characters that the player can name, you can use different variables for each character.

2 Likes

I was scrolling thru the forum and found somebody who would write their code with parent_firstname (not accurate, but I think you might know the one, they type of code, I’m referring to)
would it be the same code *create name “Unknown” on the startup page or would it look different?

thank you very much, worked like a charm!! does this mean that if the player chooses their name, because I added the box that allows them to write in their name, it still stay as the choice they made throughout the story as long as my code when referring to the player is ${firstname}

No problem! Yes, it will stay the same as long as you use the exact same variable name.

If you intend to use firstname, don’t forget to change the input name choice (and any other relevant commands) to use that variable. So, it will be *create firstname "Unknown" and *input_text firstname .

1 Like

perfect! thank you so much for helping me out!:two_hearts:

1 Like

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