Customizable Character name question
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.
Customizable Character name question
I have figured out how to have a character make their own charcter name through renpy.input, but I still want a default name. Unfotunatly I can't figure this out (all attempts i've tried fail).
I don't care if its either pressing [Enter] and leaving the name blank or having the name start with the default name and the player can backspace it...
I don't care if its either pressing [Enter] and leaving the name blank or having the name start with the default name and the player can backspace it...
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
-
- Miko-Class Veteran
- Posts: 576
- Joined: Fri May 07, 2004 9:40 am
- Completed: GO! Magical Boy (2006), Angelic Orbs (soundtrack)
- Projects: Cyberlin (in progress)
- Location: Finland
- Contact:
Defaulting to a name when the player presses ENTER is an easy one, here's the snippet from Go! Magical Boy:
Code: Select all
$ player_name = renpy.input("What is your name, Magical Boy?")
# A little hommage to Seasons of Sakura:
if player_name == "":
$ player_name="Shuji"
- PyTom
- Ren'Py Creator
- Posts: 16097
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
It's probably best to do a
$ name = name.strip()
immediately after reading in a name. This strips off any whitespace surrounding the name. This will make the names "" and " " into the same thing, and will prevent layout problems if the user is overly generous with whitespace.
(Now I need to go reverse-engineer a recent release of G!MB.)
$ name = name.strip()
immediately after reading in a name. This strips off any whitespace surrounding the name. This will make the names "" and " " into the same thing, and will prevent layout problems if the user is overly generous with whitespace.
(Now I need to go reverse-engineer a recent release of G!MB.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
To address the original question, I personally used:
This puts Alex in as the default name, but the player can choose to backspace over it and use their own.
Thanks for the name.strip info, PyTom! I know that when I had my brother playtesting my game, he pressed the space bar at the name input screen before hitting Enter and ended up with the name "Alex " (with an extra space).
Code: Select all
$ name = renpy.input("Your name is...","Alex",length=12)
Thanks for the name.strip info, PyTom! I know that when I had my brother playtesting my game, he pressed the space bar at the name input screen before hitting Enter and ended up with the name "Alex " (with an extra space).
That might be better due to the game i'm making actually, though the if statement is always a good backup if someone leaves the name blank after backspacing.Quin wrote:To address the original question, I personally used:This puts Alex in as the default name, but the player can choose to backspace over it and use their own.Code: Select all
$ name = renpy.input("Your name is...","Alex",length=12)
Thanks for the name.strip info, PyTom! I know that when I had my brother playtesting my game, he pressed the space bar at the name input screen before hitting Enter and ended up with the name "Alex " (with an extra space).
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
Who is online
Users browsing this forum: Bing [Bot], giorgi1111