Renpy dialogue depending on player's name

gargamel44

Member
May 11, 2023
198
392
The question is short. In renpy you can have the option of letting the player decide the MC's name. What I want to know is how can I change dialogue depending on that name.

For example, if at the beggining you name yourself "Anna" and then later in the game appears a character whose name is Anna too, the dialogue would have a short change and the character would say something like "Hey, we share names!".

I know it's silly but I can't find the answer for some reason. Ty
 

michaelisabarber

New Member
Sep 18, 2019
8
58
if mc.name.lower() == "anna":
mc "Hey your name is the same as mine! Give it back!"
e "Not this again, stop it Anna!"


You want to use .lower() so it's easier to compare in case someone decides to put something like "AnnA"
I gave it a quick test because I'm a little rusty with renp'y and it seems to work.
 
Last edited:

gargamel44

Member
May 11, 2023
198
392
if mc.name.lower() == "anna":
mc "Hey your name is the same as mine! Give it back!"
e "Not this again, stop it Anna!"


You want to use .lower() so it's easier to compare in case someone decides to put something like "AnnA"
I gave it a quick test because I'm a little rusty with renp'y and it seems to work.
Thanks! I did what you said but it didn't work, probably because I made some rookie mistake (I know almost 0 about coding)

This is my sequence:

saya "Secondly, I was waiting for you two, Jim."
scene 317
with dissolve
if y.name.lower() == "Jim":
y "Awww, thanks..."
y "I'm going to get something to eat."
y "Awww, thanks... wait who?"
y "Whatever, I'm gonna get something to eat..."

I want the character to say a different thing depending on his name. If he's named Jim, then he doesn't react to what "saya" says. If he's called something else, then he wonders who is Jim.
 

michaelisabarber

New Member
Sep 18, 2019
8
58
Thanks! I did what you said but it didn't work, probably because I made some rookie mistake (I know almost 0 about coding)

This is my sequence:

saya "Secondly, I was waiting for you two, Jim."
scene 317
with dissolve
if y.name.lower() == "Jim":
y "Awww, thanks..."
y "I'm going to get something to eat."
y "Awww, thanks... wait who?"
y "Whatever, I'm gonna get something to eat..."

I want the character to say a different thing depending on his name. If he's named Jim, then he doesn't react to what "saya" says. If he's called something else, then he wonders who is Jim.
if y.name.lower() == "Jim": should be if y.name.lower() == "jim":, I think?

I think that's the problem? Should be lowercase as lower() makes the players name all lowercase. (just in case it is the same but with different capital letters so they could be named "JIM'' or "JiM"')


I'm still getting used to this stuff again, sorry. I tested this and it seems to work:


"I must've drunk too much again, I forgot my name!"
$ y.name = renpy.input("Ugh, what was it again?")
$ y.name = y.name.strip()
"Pleased to meet you, %(y)s!"
scene bg room
if y.name.lower() == "james":
y "Hey your name is the same as mine! Give it back!"
j "Not this again, stop it %(y)s!"

show eileen happy
j "It's almost time for school, as cliche as that sounds!"
y "Well anyway, what are you doing here?! It's 5:30!"


Just incase I read the question wrong, you can change your player name in other characters speech by using %(y)s.
 
Last edited:

gargamel44

Member
May 11, 2023
198
392
if y.name.lower() == "Jim": should be if y.name.lower() == "jim":, I think?

I think that's the problem? Should be lowercase as lower() makes the players name all lowercase. (just in case it is the same but with different capital letters so they could be named "JIM'' or "JiM"')


I'm still getting used to this stuff again, sorry. I tested this and it seems to work:


"I must've drunk too much again, I forgot my name!"
$ y.name = renpy.input("Ugh, what was it again?")
$ y.name = y.name.strip()
"Pleased to meet you, %(y)s!"
scene bg room
if y.name.lower() == "james":
y "Hey your name is the same as mine! Give it back!"
j "Not this again, stop it %(y)s!"

show eileen happy
j "It's almost time for school, as cliche as that sounds!"
y "Well anyway, what are you doing here?! It's 5:30!"


Just incase I read the question wrong, you can change your player name in other characters speech by using %(y)s.
Yes, it worked, thanks!! Now the only thing that is left is to make the other two messages trigger when it's right. I want them to trigger only if the character isn't named Jim, meaning, every other input. To make it clear: they don't trigger if the player is named Jim, but they do with every other name. Got any clue?