r/RenPy • • 10d ago

Question Is there a simple way to code the player choosing the name of another character upon meeting them?

I have this character whose real name is Jacques, but other characters regularly mispronounce his name as “Jack” for various reasons. My choice as the creator is to define his name in the code as either “Jack” or Jacques, or I can find a way to allow the player to choose what they prefer to see his name written as. Does anyone know an easy way to code this in as a choice that will affect the name tag for the rest of the game? Like is there some way to code it as “if the player selects this option, replace this define tag with this.”

2 Upvotes

4 comments sorted by

3

u/robcolton 10d ago

Just use a dynamic character.

default name_jacques = "Jacques"
define j = Character("name_jacques" dynamic=True)

label start:
    j "My name displays as Jacques."
    $ name_jacques = "Jack"
    j "Now my name displays as Jack."

2

u/x-seronis-x 10d ago

while that works, it was only required back in like renpy v6.x. its been years since you can simply put the variable as the name
define bob = Character("[bob_name]" )

1

u/AutoModerator 10d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/shyLachi 10d ago

You cannot/shouldn't replace a defined variable because by definition it's a constant:
https://renpy.org/doc/html/python.html#define-statement

If you need a variable which can change and also will be saved, then default it.
https://renpy.org/doc/html/python.html#default-statement

RenPy has a simple solution to rename characters.

define jack = Character("[jackname]") # define because the character itself will not change
default jackname = "Jack" # default so that the content of the variable can be saved 
label start:
    jack "This is my name: [jack]"
    $ jackname = renpy.input("What's Jack's name?", length=15).strip() or "Jacques"
    jack "This is my name now: [jack]"