How to change a character's name partway into the game?

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
tobesomething
Newbie
Posts: 11
Joined: Fri Oct 24, 2014 9:44 pm
Projects: Unnamed LGBT Slice of Life
Tumblr: ewnerds
Contact:

How to change a character's name partway into the game?

#1 Post by tobesomething »

The title sounds really confusing because I wasn't sure how to word this but basically I'm making a visual novel about this transfeminine character and at first she's referred by her birth name by everyone, but then she finally comes out and her real identity is known, so I need the name shown above her dialogue to reflect that change.

How would I go about doing this? Is it even possible?

I want someone to ask her her preferred name and then for a box to pop up allowing the player to type in a name, so then that's what shows up when she speaks from then on. I know how to do that at the beginning of the game, but I'm unsure how to do that when the character has been referred to as something else for a large period of time. I don't know, I'm very new at coding so maybe this is obvious but *shrug*. Thanks for your time!

User avatar
Kate
Regular
Posts: 197
Joined: Thu Sep 19, 2013 6:10 pm
Projects: Blackout
Organization: Moonlight Otome
Location: United States
Contact:

Re: How to change a character's name partway into the game?

#2 Post by Kate »

Here you go!

This is the key function you need:

Code: Select all

$ p = renpy.input ("My name is", "", length=20,)
if p == "":
    $ p = "Alex" #default name if player leaves custom box blank

Here's an example of how you could use it:

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define p = Character('[p]', color="#c8ffc8")
define k = Character('Kate', color="#c8ffc8")

# The game starts here.
label start:

    k "This is your game!"


k "Welcome!"

k "First, this is your character's starting name!!"

k "If you wish for it to be a static, pre-chosen name, just define above!"
# up above, under declare characters, is where you name the person.
#define p = Character('[p]', color="#c8ffc8")

# let's say you name the person Tonya.
#define p = Character('Tonya', color="#c8ffc8")
# and then you omit the function I've placed below.


$ p = renpy.input ("My name is", "", length=20,)
if p == "":
    $ p = "Alex" #default name if player leaves custom box blank


# [p] is how you address the character in a sentence.
# p is the character's voice.


k "Very good, [p]!"
k "Well, you're stuck with this name, [p]. Or are you? Want to change your name?"


$ p = renpy.input ("My name is now changing to...", "", length=20,)
if p == "":
    $ p = "Sam"
    
k "This should work just fine! Right, [p]?"
k "The end!"

return
Basically- this changes the name. I noted in the commented out spots what to omit if You are picking the original name vs. if the player sets both the original name and then the second name. [p] is what you use to have another character refer to that custom name. p is, as usual, the "shortcut" for names and such. Some make a longer tag, such as "player" but using p keeps it easier and quicker, in my opinion.
Current Project:
Blackout [VN][Romance][GxB][Mystery][Suspense] http://lemmasoft.renai.us/forums/viewto ... 43&t=34118
"It is the duty of authors to make the fantastic seem ordinary and the ordinary seem fantastic." - K. Auer

User avatar
tobesomething
Newbie
Posts: 11
Joined: Fri Oct 24, 2014 9:44 pm
Projects: Unnamed LGBT Slice of Life
Tumblr: ewnerds
Contact:

Re: How to change a character's name partway into the game?

#3 Post by tobesomething »

Kate wrote:snip
Thank you, that helped a lot! :D

Post Reply

Who is online

Users browsing this forum: Ocelot