Hello, im trying to have the players in my game have the option to name their character unless they want to. please advise on the following code
# People
define m = Character("Mia")
define a = Character("Allison")
define k = Character("Kira")
define v = Character("Veronica")
define x = Character("[player_name]")
# The game starts here.
label start:
scene black
"Would you like to choose your name?"
menu:
"Yes":
jump choosename
return
"No":
jump introscene
return
label choosename:
scene black
$ player_name = renpy.input ("What is your name?")
$ player_name = player_name.strip()
if player_name == "":
$ player_name ="Adam"
label introscene:
scene misa
m "Pleased to meet you, %(player_name)s"
x "Got a name!!"
m "This is a test"
the game picks up the custom name that the player inputs but I get an error if they choose no in the options
Custom Name error
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
- Newbie
- Posts: 6
- Joined: Tue Apr 24, 2018 1:55 pm
- Contact:
Re: Custom Name error
That because if they skip, the player_name variable is not declared at all.
Add this in your code just after the characters and it'll fix it:
You can also remove the line
Add this in your code just after the characters and it'll fix it:
Code: Select all
default player_name = "Adam"
Code: Select all
$ player_name = "Adam"
-
- Newbie
- Posts: 6
- Joined: Tue Apr 24, 2018 1:55 pm
- Contact:
Re: Custom Name error
It worked!! thank you so much
Who is online
Users browsing this forum: MSN [Bot]