Code: Select all
default mc = "Guy"
Code: Select all
define p = Character("[mc]")
Code: Select all
label start:
# You're game here.
e "Hello, you're the new student! What's your name?"
label nameMC:
# game continues
Code: Select all
$ mc = renpy.input("What's your name?")
Code: Select all
$ mc = renpy.input("What's your name?", length=10)
Do I want to assume that all spaces are mistypes on the keyboard and use $ mc = mc.strip() to get rid of it, or do I want players to have a space in their names? So they can "Ellie von Nirenberg" (Not that the name would fix with a 10 character limit)
Also some names have apostrophes in them like R'aihir. If you're going to only allow lower and uppercase letters you're missing out on those. So add it if you want to at the end like this.
Without a space so you don't have the .strip() the name.
Code: Select all
$ mc = renpy.input("Please give her a name. Max 10 characters", allow="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
Code: Select all
$ mc = renpy.input("Please give her a name. Max 10 characters", allow=" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
You're almost done right! Nope. Before you allow a name to go on you can do a few more things. One is to make sure they just didn't hit enter, setting the variable of mc to nothing.
Code: Select all
if mc == "":
"You didn't enter anything for her name."
jump nameMc
Code: Select all
$ mc = mc.title()
Another thing you can check is how many characters are in the name the player has inputted. Without it you can have people calling their characters X or worse if you let them use apostrophes '. So to change that write this:
Code: Select all
if mc is not None:
$ check_name = len(mc)
if check_name == 1:
"You must name your character a minimum of 2 letters."
jump nameMC
Code: Select all
if mc == " ":
"You didn't enter anything for her name."
jump nameMc
Code: Select all
default mc = ""
define e = Character('Eileen')
define p = Character("[mc]")
label start:
# You're game here.
e "Hello, you're the new student! What's your name?"
label nameMC:
$ mc = renpy.input("Please give her a name. Max 10 characters", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=10)
if mc == "":
"Please give your character a name that is between 2-10's characters long."
jump nameMc
if mc is not None:
$ check_name = len(mc)
if check_name == 1:
"You must name your character a minimum of 2 letters."
jump nameMC
$ mc = mc.title()
# Yay, your name doesn't hit any conditions. You can name them that!
e "[mc]...well you're not on the list!"
menu:
"You want to name them [name]?"
"No":
jump nameMc
"Yes":
pass
player "I'm just new."
# game continues
return