In the choice menu, if you choose the default name option, it will just not change anything. Since you have never given player_name
a value, it will not be "Heidi" but just a blank "None". The "Heidi" part in the code you set is only for what is automatically in the textbox for the input section. If you never go through there, it doesn't actually change the value of the variable player_name
. So you'll get errors later if you want to use player_name
in something else (because it doesn't exist yet).
Just add this BEFORE the "label start" section (and before you define the characters):
that should work. The default
action will only make the player_name
into "Heidi" if it has nothing yet (so after pressing "new game"). If you load a game, and you put in a different name, it should be fine too.
Watch your indentations. Always use the same distance of 4 spaces (or 1 tab, but that doesn't always work with all editor types). You'll get errors left and right otherwise, sooner or later.
So your final code should be something like this:
Code: Select all
default player_name = "Heidi"
define h = character ("[player_name]")
# And something to define n, which you probably did somewhere here?
n "Do you want to leave the default name?"
n "Or do you want to input your own name?"
menu: # This one is 1 space too much to the right? Don't do that!
"I want to leave the default name":
jump default # Don't put this all the way to the right, either!
"I want to input my own name":
jump yourname # This one too. Use only 1 indentation (4 spaces) per tier.
label default: # Labels generally go to the far left again. Not always, but generally they should.
n "Default name it is!"
n "Then tell me your name."
$ player_name = renpy.input ("What is your name?", "Heidi")
$ player_name = player_name.strip() # You had some strange varialbe f_name instead of player_name. Not sure why. Maybe a remnant from something you copied?
if player_name == "":
$ player_name = "Heidi"
n "Ok, you are now [player_name]!"