About Letting The Player Choose Their Name...

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
User avatar
Dollarluigi
Regular
Posts: 63
Joined: Mon Aug 15, 2016 10:06 pm
Completed: Winter Dream, School For The Friendless
Tumblr: Rehnchoro
Deviantart: Dollarluigi
Skype: Dollarluigi
Soundcloud: Dollarluigi
Location: Probably Earth
Contact:

About Letting The Player Choose Their Name...

#1 Post by Dollarluigi »

I've already looked it up and I found a way for the player to enter their name, so I can get other characters to refer to the player as whatever name they enter, but I have a couple of questions. How do I limit the amount of characters that can be in the name and how do I get the name the player entered to appear in the text box to show when the player is talking?
Suffering a rare condition is one of the worst things you could ever experience because no one understands a thing.

YouTube Twitter Tumblr Reddit deviantArt

User avatar
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

Re: About Letting The Player Choose Their Name...

#2 Post by Katy133 »

I made a tutorial on naming characters.

I'll quote what you specifically wanted below:

Code: Select all

$ custom_name = renpy.input ("I need to name myself." length=10)
"Length=10" means "A name that's 10 letters or characters long"

In the linked tutorial, I also included instructions on how to add custom responses to the player typing in specific names (you can use this to either prevent the player from typing in swear words or to include Easter Eggs to certain names).

Hope this helps! :D
Last edited by Katy133 on Tue Jun 27, 2017 10:36 am, edited 1 time in total.
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

User avatar
Dollarluigi
Regular
Posts: 63
Joined: Mon Aug 15, 2016 10:06 pm
Completed: Winter Dream, School For The Friendless
Tumblr: Rehnchoro
Deviantart: Dollarluigi
Skype: Dollarluigi
Soundcloud: Dollarluigi
Location: Probably Earth
Contact:

Re: About Letting The Player Choose Their Name...

#3 Post by Dollarluigi »

Katy133 wrote:I made a tutorial on naming characters.

I'll quote what you specifically wanted below:

Code: Select all

$ custom_name = renpy.input ["I need to name myself." length=10)
"Length=10" means "A name that's 10 letters or characters long"

In the linked tutorial, I also included instructions on how to add custom responses to the player typing in specific names (you can use this to either prevent the player from typing in swear words or to include Easter Eggs to certain names).

Hope this helps! :D
It doesn't unfortunately.
Perhaps my code will help?

Code: Select all

   $ player_name = renpy.input("What is your name?")
    
    $ player_name = player_name.strip()

    if player_name == "":
        $ player_name="Matt"
Also, what I really want to know is how to get the name to appear on the textbox. What do I have to use for a character's name when I want to do that? Everything I've tried has failed.

Code: Select all

define p = Character('%(player_name)s', color="#0017FF")
Suffering a rare condition is one of the worst things you could ever experience because no one understands a thing.

YouTube Twitter Tumblr Reddit deviantArt

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: About Letting The Player Choose Their Name...

#4 Post by trooper6 »

Code: Select all

default player_name = ""

define p = Character("[player_name]", color="#0017FF")

label start:
    $ player_name = renpy.input("What is your name?", length=10)  
    $ player_name = player_name.strip()
    if player_name == "":
        $player_name="Matt"
You may want to look at the documentation: https://www.renpy.org/doc/html/input.html
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Katy133
Miko-Class Veteran
Posts: 704
Joined: Sat Nov 16, 2013 1:21 pm
Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
Projects: The Butler Detective
Tumblr: katy-133
Deviantart: Katy133
Soundcloud: Katy133
itch: katy133
Location: Canada
Contact:

Re: About Letting The Player Choose Their Name...

#5 Post by Katy133 »

Dollarluigi wrote:It doesn't unfortunately.
Perhaps my code will help?
You will need to change "custom_name" to whatever tag you are currently using (in this case, "player_name"). Also, be sure you are using (brackets) and not [square brackets]

Try this:

Code: Select all

   $ player_name = renpy.input("What is your name?" length=10)
    
    $ player_name = player_name.strip()

    if player_name == "":
        $ player_name="Matt"
ImageImage

My Website, which lists my visual novels.
Become a patron on my Patreon!

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: About Letting The Player Choose Their Name...

#6 Post by DannyGMaster »

I solved this problem by making a function that changes a character's name directly.

Code: Select all

init python:

    def input_name(character):

        new_name = renpy.input("What is your name?", length=9)
        new_name = new_name.strip()

        if not new_name: #So if the player hits enter the default name is used.
            pass
        else:
            character.name = new_name

define m = Character("Matt") #You define the character with his/her default name

label start:
    m "I'm [m.name] but you can change my name!"

    $ input_name(m) #The player changes his her name here.

    m "Now I'm called [m.name]!"
I think this way you can refer to your character's more clearly, and even have the player name more than one character.
The silent voice within one's heart whispers the most profound wisdom.

Post Reply

Who is online

Users browsing this forum: Google [Bot]