Change character name depending on "Sayer"

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
recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Change character name depending on "Sayer"

#1 Post by recreation »

I have a lot of characters and some of them use different names for the player (Sweetheart, Hun, Daddy, Bro, Brother, etc.), the player can also chose how he wants to be called, so if he want's to be called by his name, he can chose so. This makes it extremely hard to remember and put the right variables all the time in the dialogue, so I thought I might be able to use callbacks, but it seems it only sets the new variable after the text for the current dialogue is already set.
For example:

Code: Select all

init python:
    def pmc_name(event,**kwargs):
        if pdaddy:
            store.mcc = "Daddy"
define p = Character("Daughter", callback=pmc_name)
default mcc = "You"
default pdaddy = True

label start:
	p "Good morning, [mcc]."
	p "Did you sleep well, [mcc]?
Will output:
"Good morning, You."
"Did you sleep well, Daddy?"


Is there a way to get the callback on the first sentence? Or is there any other method? Maybe some way to check who is the Sayer?

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Change character name depending on "Sayer"

#2 Post by hell_oh_world »

how about you use this type of callback instead? https://www.renpy.org/doc/html/config.h ... s_callback

recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Re: Change character name depending on "Sayer"

#3 Post by recreation »

hell_oh_world wrote: Sun Dec 20, 2020 5:22 pm how about you use this type of callback instead? https://www.renpy.org/doc/html/config.h ... s_callback
Sounds like it will do the same but I'd like to try, problem is I have no idea how to use it. The documentation about character callbacks is a little bit more precise so I could figure it out, but this... :shock:

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Change character name depending on "Sayer"

#4 Post by philat »

I would imagine it would be preferable to keep the variables, as this lends more flexibility and character to the dialogue anyway. Are you saying that all characters will only ever call the mc one thing?

recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Re: Change character name depending on "Sayer"

#5 Post by recreation »

philat wrote: Mon Dec 21, 2020 1:37 am I would imagine it would be preferable to keep the variables, as this lends more flexibility and character to the dialogue anyway. Are you saying that all characters will only ever call the mc one thing?
No it's partially choice made by the player, some characters also start of calling the mc by his name, but later use a nickname for him, so it's dependant on several conditions.
What I was thinking of was somehow get the sayer before the dialogue is shown, so I can ask for these conditions and chance the displayed name (within the dialogue, not the sayer name).
Something like:

Code: Select all

if Sayer == "Daughter" and pdaddy:
	mcc = "Daddy"
if Sayer == "Waifu" and wnickname:
	mcc = "Babe"
label start:
	p "Hello, [mcc]." #mcc = Daddy
	w "Hey, [mcc]!" #mcc = Babe
This obviously doesn't work, but I thought it might help explaning what I'm trying to do.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Change character name depending on "Sayer"

#6 Post by philat »

No, what I mean is why wouldn't you just have a variable for each nickname and use it accordingly. So your daughter might only ever call you daddy (or whatever else the mc chooses) but it is unrealistic for your SO or brother, for example, to ONLY call you a nickname like sweetheart or bro. And the burden of writing "Hi, [daddy.]" or "Good morning, [sweetheart]." does not seem significantly higher than what you are trying to do. There's probably a way to do what you want but due to the order of operations on how stuff is handled by the engine it's probably annoying to figure out.

recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Re: Change character name depending on "Sayer"

#7 Post by recreation »

I know what you mean, but like I said, there are a lot of characters in the game and many of them have different names for the mc. Right now there are 12 different chars that can call the mc by a different name, and there are going to be more in the future.
Using a different variable for every character is not the end of the world, but simply put it's a pain in the ar... especially if you write a big block of dialogue with different people talking.
There's probably a way to do what you want but due to the order of operations on how stuff is handled by the engine it's probably annoying to figure out.
Yes I kind of expected that and didn't have high hopes tbh, but I figured why not ask anyway because you never know. Sometimes someone comes up with an amazingly simple solution nobody thought about before^^

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Change character name depending on "Sayer"

#8 Post by hell_oh_world »

recreation wrote: Mon Dec 21, 2020 12:58 am
hell_oh_world wrote: Sun Dec 20, 2020 5:22 pm how about you use this type of callback instead? https://www.renpy.org/doc/html/config.h ... s_callback
Sounds like it will do the same but I'd like to try, problem is I have no idea how to use it. The documentation about character callbacks is a little bit more precise so I could figure it out, but this... :shock:
Well, if you have clicked the link you'll see the example you're looking for.
And this is pretty much the same as character callbacks so I assumed you already have an understanding of implementing callbacks.
You can try it as:

Code: Select all

init python:
  def say_arguments_callback(who, interact=True, *args, **kwargs):
      kw = {}
      kw.update(dict(interact=interact))
      kw.update(kwargs)
      
      if who == store.daughter.name:
        store.endear = "Father"
        
      return args, kw

  config.say_arguments_callback = say_arguments_callback
  
define daughter = Character("Veronica")
default endear = "You"
Not sure if it will work the way intended as I didn't really try this.
And how are you planning to make the endearment dynamic in this case? Because you still need to store player's preferences of endearment per character somehow on a variable to do the switching of names automatically. And wouldn't that be the same as what you're trying to avoid in the first place? no?

recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Re: Change character name depending on "Sayer"

#9 Post by recreation »

hell_oh_world wrote: Mon Dec 21, 2020 5:59 am Well, if you have clicked the link you'll see the example you're looking for.
And this is pretty much the same as character callbacks so I assumed you already have an understanding of implementing callbacks.
You can try it as:

Code: Select all

init python:
  def say_arguments_callback(who, interact=True, *args, **kwargs):
      kw = {}
      kw.update(dict(interact=interact))
      kw.update(kwargs)
      
      if who == store.daughter.name:
        store.endear = "Father"
        
      return args, kw

  config.say_arguments_callback = say_arguments_callback
  
define daughter = Character("Veronica")
default endear = "You"
Not sure if it will work the way intended as I didn't really try this.
And how are you planning to make the endearment dynamic in this case? Because you still need to store player's preferences of endearment per character somehow on a variable to do the switching of names automatically. And wouldn't that be the same as what you're trying to avoid in the first place? no?
I did, but while I understood half of the character callback and figured the rest by trying and testing, here I didn't even understand half of it^^
Your example makes a lot more sense to me, but it doesn't seem to work at all, the mc name (endear) won't change.
And how are you planning to make the endearment dynamic in this case? Because you still need to store player's preferences of endearment per character somehow on a variable to do the switching of names automatically. And wouldn't that be the same as what you're trying to avoid in the first place? no?
No I would just have to add another condition to the callback.

Code: Select all

if who == store.daughter.name and somevar:
Or am I missing something here?

Post Reply

Who is online

Users browsing this forum: No registered users