Customizable Character name question

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
Jinnai
Regular
Posts: 36
Joined: Tue Oct 07, 2003 7:32 pm
Contact:

Customizable Character name question

#1 Post by Jinnai »

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...
)'.'(
Power of Sqyishyness!!

Alessio
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:

#2 Post by Alessio »

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"

User avatar
mikey
Lemma-Class Veteran
Posts: 3249
Joined: Sat Jan 10, 2004 6:03 am
itch: atpprojects
Contact:

#3 Post by mikey »

But... we don't know that the default name is Shuji... I never even thought of pressing ENTER when asked for input. :?
It's like a little easter egg ^_^

Alessio
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:

#4 Post by Alessio »

Yes, that was the idea. And there's one more easter egg in the name input section (but not worth searching for). :)

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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:

#5 Post by PyTom »

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.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jinnai
Regular
Posts: 36
Joined: Tue Oct 07, 2003 7:32 pm
Contact:

#6 Post by Jinnai »

Thanks everyone.
)'.'(
Power of Sqyishyness!!

Alessio
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:

#7 Post by Alessio »

PyTom wrote:(Now I need to go reverse-engineer a recent release of G!MB.)
Nothing much to find there except a debugging menu with some practical jumping and variable-setting options... but the first one to guess which name you need to type in will get a cameo appearance in my next VN. :)

User avatar
Quin
Regular
Posts: 117
Joined: Sun Nov 20, 2005 4:29 am
Location: Maine
Contact:

#8 Post by Quin »

To address the original question, I personally used:

Code: Select all

$ name = renpy.input("Your name is...","Alex",length=12)
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).

Jinnai
Regular
Posts: 36
Joined: Tue Oct 07, 2003 7:32 pm
Contact:

#9 Post by Jinnai »

Quin wrote:To address the original question, I personally used:

Code: Select all

$ name = renpy.input("Your name is...","Alex",length=12)
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).
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.
)'.'(
Power of Sqyishyness!!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]