Ren'Py Adding a Character in Game

tripod70

Not so Well-known Member
Game Developer
Oct 23, 2020
2,221
3,976
I am planning to ad a temp character for a few scenes. She is just visiting, and after she leaves wont be back in the game.

Can I just add a definition for her where I am at in the script, or do I have to put her at the top where the definitions are now???
I can't seem to find that in the doc's for Renpy...
 

Playstorepers

Member
May 24, 2020
160
79
define is the best way to add any character (temp or not).
every playthrough creates that character.

you could theoretically add them in your script, but it's messy at best and buggy at worst.

just use define outside of your script and you should be fine (It's best to do that for all of your characters). Create an rpy file with variables for example and stuff all your characters in there with define.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
There are a few options.

Firstly (and most common), you just add a define unk1 = Character("Unknown Person #1") style definition into the mix.

Because it's a define, it can appear anywhere in the code. RenPy doesn't care. RenPy scans for certain statements during startup and processes them immediately, define is one of those statements. That said, I think most of us would suggest adding it to the same place as the other Character() definitions (i.e. probably at the top of the code). There's no technical reason, but it's still "neater" and what the majority of us would expect to see in well written code.

Secondly, there's the option that barely anyone even knows is possible, which is to not use a predefined character object at all.

Normally, you'd expect to see code like:

Python:
    e "Hello and welcome to my game."
    mc "Thanks."
    s "Same, thanks. I'm [mc]'s sister."

But you can just hard code the name of the character instead of using a Character(). Like:

Python:
    "Eileen" "Hello and welcome to my game."
    mc "Thanks."
    "Stacy" "Same, thanks. I'm [mc]'s sister."

It doesn't make much sense for main or primarily characters. Even secondary characters who speak a lot, usually do enough to warrant their own Character() definition.

But characters with only one or two lines, who will never be seen again... it might be worth it.

In your case, it might be something like:

Python:
    "Barista" "What can I get for you today?"

Again, I think most of us would expect a Character() definition, even for a character with 2 lines. Mostly just due to familiarity. The other reason to always use Character() based characters is the customization options. Maybe it doesn't matter to you, but I tend to use colors to differentiate women from men or love interests from background characters. I also tend to use what_prefix= and what_suffix= a lot more than average to differentitate spoken dialogue, character thoughts and non-character narration. None of which can be done if you hard code the character name against each dialogue line.
 

tripod70

Not so Well-known Member
Game Developer
Oct 23, 2020
2,221
3,976
I guess I could just add her up where the rest of them are instead of way down in the code when she shows up
 

Lou111

Active Member
Jun 2, 2018
543
686
Just to add a little tip to what 79flavors said:

If the only reason you're defining a character rather than using
Python:
 "Barista" "What can I get for you today?"
is that you want to customize the color or font etc you can also add
Python:
 "{color=#B20150}Barista" "What can I get for you today?"
For temp characters that I add I only define them if they need a customized window background...
 

tripod70

Not so Well-known Member
Game Developer
Oct 23, 2020
2,221
3,976
Just to add a little tip to what 79flavors said:

If the only reason you're defining a character rather than using
Python:
 "Barista" "What can I get for you today?"
is that you want to customize the color or font etc you can also add
Python:
 "{color=#B20150}Barista" "What can I get for you today?"
For temp characters that I add I only define them if they need a customized window background...
Thanks. She is only going to be there as a visitor for a few scenes only. Then gone....... I don't think she will stay, but one never knows. :) It would be my luck that she is popular... :)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
is that you want to customize the color or font etc you can also add
Python:
 "{color=#B20150}Barista" "What can I get for you today?"
This made me question how far one can go this way...

And the answer is: Oh my fucking good, what funny things can be done here.

In short, if a dialog line is composed of two strings into quotation marks (I assume that simple quotes works as well, but I haven't tested), the first string will be the name, and the second will be the dialog line by itself. And the name will be proceeded like any other string, what mean that it handle interpolated text ; it's your use of a tag that make me think about this.

In the end, you can do things like that:
Code:
label start:
    $ name = "{color=#FF0000}AON{/color}"
    "[name]" "So, this is working..."
    $ name = "{color=#00FF00}AON{/color}"
    extend "And this is fuckingly interesting."

    $ theName = "{color=[color]}[name]{/color}"
    $ name = "AON"
    $ color = "#FF0000"
    "[theName!i]" "You know, I'm angry !"
    $ color = "#00FF00"
    "[theName!i]" "But you're too pretty, I'm never angry for a long time."
    "END"
    return
Side note: The !i is the that permit to add a level of interpolation ; therefore interpolate text inside interpolated text.
 
  • Jizzed my pants
Reactions: Lou111

tripod70

Not so Well-known Member
Game Developer
Oct 23, 2020
2,221
3,976
:) I will have to ponder on all of this when it gets closer to the time it will be needed.

It's a lot to take in at one time when I haven't made the renders or script that far out yet.... :eek::LOL:
 

Lou111

Active Member
Jun 2, 2018
543
686
And the answer is: Oh my fucking good, what funny things can be done here.
Whaaa that extend is new stuff for me! What I was doing before to emulate that is too embarrassing to post here but it was pretty bad...
So I stopped being lazy and googled what interpolate means (basically defines a dildo) and I think that's what I need to learn about next :LOL:

tripod70
Yeppers. Just post what you don't get when it comes time. Basically define the character if you need it to have a side image or customized window. Otherwise just use 2 strings. "Bob" "Sup"

or
Python:
label start:
    $ bob = "Bob"
    bob "sup"