Ren'Py how to add side images to this script

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Isn't this just a variation on your other thread?
https://f95zone.to/threads/how-to-add-side-image.68602/

Because the answer is the same.
I appreciate it's probably a different game, but if you understand WHY it works - it's should still be easy to add side images. Since you were already using side images, it seemed you already knew why things were done the way they were.

The DynamicCharacter() may or may not be an issue, but to my mind there is no downside to reverting them back to "normal" Character() definitions and adding square brackets [ ] to the variable names so that it's just treated like a standard text substitution using variables.

From line #41,705 - it would instead look like this...

Python:
    define ps = Character("[ps_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)])
    define m = Character("[m_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define x = Character("[x_name]", color="#ffbcbc", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)]) 
    define f = Character("[f_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)]) 
    define pf = Character("[pf_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)]) 
    define d = Character("[d_name]", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)])
    define w = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define s = Character("[s_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)])
    define a = Character ("[a_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)])
    define l = Character ("[l_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)])
    define n = Character ("[n_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
    define q = Character ("[q_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
   
    define mu = Character("", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])
    define fu = Character("", color="#5998ff", what_color="#fff", what_outlines=[(1, "#3267bc", 0, 0)])
    define w2 = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])

    # blah, blah, more code.

But onward to . (I strongly suggest reading the documentation).

Side images are an implicit definition.

You don't directly define side images, but you can create an association between the character and a set of images that are linked to it (usually to show foreground sprites for the character in different poses/moods/clothing). That is done us using the image= parameter for the Character().

The example in the documentation is:

Python:
define e = Character("Eileen", image="eileen")

image eileen happy = "eileen_happy.png"
image eileen concerned = "eileen_concerned.png"

The "implicit" bit is that once that you've established that link between character e and image eileen ... - that link is also used when you have an image named side. It's not a direct connection, but instead something RenPy does FOR you, so you don't need to do all the heavy lifting.

So expanding the example above to include a side image...

Python:
define e = Character("Eileen", image="eileen")

image eileen happy = "eileen_happy.png"
image eileen concerned = "eileen_concerned.png"

image side eileen = "side_eileen.png"

... and that's it. As long as you have a define {char} = Character( ..., image="{imgname}") and a matching image side {imgname} = "{image_filename}" ... then you'll get a side image for that character (assuming the image file exists of course).

There's a load of customization possible to resize thing or reposition things. But those are the basics.

In your specific example, a lot of those characters can be named by the player - so the idea that Eileen's character has side images called "side eileen" isn't quite as obvious. But RenPy doesn't care what the image= points to, as long as it exists and is unique.

It helps if you're the original author, because invariably the author has a name in mind, even if they don't force it on the player. So for example, in this game, pf_name is the variable used to store the name of the player's father (so I assume pf = player father).

Guessing... maybe m_name is for Mom, a_name is for Anne... who knows?

But you can be completely arbitrary. Instead of using "eileen" for eileen... you could use any old name. Given that I've never played this game and some of the code is clearly still missing (Character "n" isn't used in this script - which implies other scripts/chapters/events)... I might pick side image names like "ps_img", "m_img", "x_img", etc. It follows the same pattern of the character definitions and their associated name variables and those identifiers aren't already used by the game.

If I were more familiar with the game, I might use "father", "mother", "anne", etc. - but that presumes I could guess what all the characters' names were going to be originally. Most games would have a fallback name used when the player doesn't pick a name for themselves - that would have helped here to use a more personalized style of naming - but this game doesn't even have that... so there are no clues.

Beyond that, some characters DO have names. Karen, Isacc, Ben, Mara, Hostess, etc. And because I know their names, I could use define b = Character("Ben", ..., image="ben") and a matching image side ben = "side_ben.png" ... and if I'd been naming all the other characters that way, I probably would. But having already decided to use identifiers like "ps_img" and "d_img", I think I'd rather remain consistent and continue to use that style of naming for the other characters too.

So IF I used those arbitrary names, my version of that code would end up looking something like:

Python:
    define ps = Character("[ps_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)], image="ps_img")
    define m = Character("[m_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)], image="m_img")
    define x = Character("[x_name]", color="#ffbcbc", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)], image="x_img") 
    define f = Character("[f_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)], image="f_img") 
    define pf = Character("[pf_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)], image="pf_img") 
    define d = Character("[d_name]", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)], image="d_img")
    define w = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)], image="w_img")
    define s = Character("[s_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)], image="s_img")
    define a = Character ("[a_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)], image="a_img")
    define l = Character ("[l_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)], image="l_img")
    define n = Character ("[n_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="n_img")
    define q = Character ("[q_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="q_img")
   
    define mu = Character("", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])
    define fu = Character("", color="#5998ff", what_color="#fff", what_outlines=[(1, "#3267bc", 0, 0)])
    define w2 = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)], image="w2_img")
    define m1 = Character("", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define du = Character("", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)])
    define sk = Character("Skeleton", color="#fff", what_color="#fff", image="sk_img")
    define k = Character ("Karen", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="k_img")
    define k2 = Character ("", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
    define g1 = Character ("Ghoulish Girl", color="#bcddff", what_color="#fff", what_outlines=[(0.5, "#3c4651", 0, 0)], image="g1_img")
    define g2 = Character ("Jawsome Girl", color="#d1a22e", what_color="#fff", what_outlines=[(0.5, "#564313", 0, 0)], image="g2_img")

    # blah, blah, more character definitions...

# somewhere else in the code... (doesn't really matter that much where)...
image side ps_img = "side_ps.png"
image side m_img = "side_m.png"
image side x_img = "side_x.png"
image side f_img = "side_f.png"
image side pf_img = "side_pf.png"
image side d_img = "side_d.png"
image side w_img = "side_w.png"
image side s_img = "side_s.png"
image side a_img = "side_a.png"
image side l_img = "side_l.png"
image side n_img = "side_n.png"
image side q_img = "side_q.png"
image side w2_img = "side_w2.png"

image side sk_img = "side_sk.png"
image side k_img = "side_k.png"
image side g1_img = "side_g1.png"
image side g2_img = "side_g2.png"
image side r_img = "side_r.png"
image side o_img = "side_o.png"
image side h_img = "side_h.png"

# blah, blah, more side images...

In my example, I've chosen not to add image= to every character (ignoring the ones that have blank names). I've only done so to demonstrate that you don't need to have a side image for every speaking character.

Likewise the naming of the actual filenames is a personal choice to keep with the naming convention I've already decided upon. I could have named them anything, but following the same pattern made more sense to me.

I hope that's enough detail to cover all eventualities.
 
  • Like
Reactions: anne O'nymous

qwerty132

Newbie
Aug 3, 2017
44
5
Isn't this just a variation on your other thread?
https://f95zone.to/threads/how-to-add-side-image.68602/

Because the answer is the same.
I appreciate it's probably a different game, but if you understand WHY it works - it's should still be easy to add side images. Since you were already using side images, it seemed you already knew why things were done the way they were.

The DynamicCharacter() may or may not be an issue, but to my mind there is no downside to reverting them back to "normal" Character() definitions and adding square brackets [ ] to the variable names so that it's just treated like a standard text substitution using variables.

From line #41,705 - it would instead look like this...

Python:
    define ps = Character("[ps_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)])
    define m = Character("[m_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define x = Character("[x_name]", color="#ffbcbc", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)])
    define f = Character("[f_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)])
    define pf = Character("[pf_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)])
    define d = Character("[d_name]", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)])
    define w = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define s = Character("[s_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)])
    define a = Character ("[a_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)])
    define l = Character ("[l_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)])
    define n = Character ("[n_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
    define q = Character ("[q_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
  
    define mu = Character("", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])
    define fu = Character("", color="#5998ff", what_color="#fff", what_outlines=[(1, "#3267bc", 0, 0)])
    define w2 = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])

    # blah, blah, more code.

But onward to . (I strongly suggest reading the documentation).

Side images are an implicit definition.

You don't directly define side images, but you can create an association between the character and a set of images that are linked to it (usually to show foreground sprites for the character in different poses/moods/clothing). That is done us using the image= parameter for the Character().

The example in the documentation is:

Python:
define e = Character("Eileen", image="eileen")

image eileen happy = "eileen_happy.png"
image eileen concerned = "eileen_concerned.png"

The "implicit" bit is that once that you've established that link between character e and image eileen ... - that link is also used when you have an image named side. It's not a direct connection, but instead something RenPy does FOR you, so you don't need to do all the heavy lifting.

So expanding the example above to include a side image...

Python:
define e = Character("Eileen", image="eileen")

image eileen happy = "eileen_happy.png"
image eileen concerned = "eileen_concerned.png"

image side eileen = "side_eileen.png"

... and that's it. As long as you have a define {char} = Character( ..., image="{imgname}") and a matching image side {imgname} = "{image_filename}" ... then you'll get a side image for that character (assuming the image file exists of course).

There's a load of customization possible to resize thing or reposition things. But those are the basics.

In your specific example, a lot of those characters can be named by the player - so the idea that Eileen's character has side images called "side eileen" isn't quite as obvious. But RenPy doesn't care what the image= points to, as long as it exists and is unique.

It helps if you're the original author, because invariably the author has a name in mind, even if they don't force it on the player. So for example, in this game, pf_name is the variable used to store the name of the player's father (so I assume pf = player father).

Guessing... maybe m_name is for Mom, a_name is for Anne... who knows?

But you can be completely arbitrary. Instead of using "eileen" for eileen... you could use any old name. Given that I've never played this game and some of the code is clearly still missing (Character "n" isn't used in this script - which implies other scripts/chapters/events)... I might pick side image names like "ps_img", "m_img", "x_img", etc. It follows the same pattern of the character definitions and their associated name variables and those identifiers aren't already used by the game.

If I were more familiar with the game, I might use "father", "mother", "anne", etc. - but that presumes I could guess what all the characters' names were going to be originally. Most games would have a fallback name used when the player doesn't pick a name for themselves - that would have helped here to use a more personalized style of naming - but this game doesn't even have that... so there are no clues.

Beyond that, some characters DO have names. Karen, Isacc, Ben, Mara, Hostess, etc. And because I know their names, I could use define b = Character("Ben", ..., image="ben") and a matching image side ben = "side_ben.png" ... and if I'd been naming all the other characters that way, I probably would. But having already decided to use identifiers like "ps_img" and "d_img", I think I'd rather remain consistent and continue to use that style of naming for the other characters too.

So IF I used those arbitrary names, my version of that code would end up looking something like:

Python:
    define ps = Character("[ps_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)], image="ps_img")
    define m = Character("[m_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)], image="m_img")
    define x = Character("[x_name]", color="#ffbcbc", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)], image="x_img")
    define f = Character("[f_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)], image="f_img")
    define pf = Character("[pf_name]", color="#5998ff", what_color="#fff", what_outlines=[(0.5, "#3267bc", 0, 0)], image="pf_img")
    define d = Character("[d_name]", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)], image="d_img")
    define w = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)], image="w_img")
    define s = Character("[s_name]", color="#faff70", what_color="#fff", what_outlines=[(0.5, "#5b5400", 0, 0)], image="s_img")
    define a = Character ("[a_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)], image="a_img")
    define l = Character ("[l_name]", color="#4fe57a", what_color="#fff", what_outlines=[(0.5, "#1f5b30", 0, 0)], image="l_img")
    define n = Character ("[n_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="n_img")
    define q = Character ("[q_name]", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="q_img")
  
    define mu = Character("", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)])
    define fu = Character("", color="#5998ff", what_color="#fff", what_outlines=[(1, "#3267bc", 0, 0)])
    define w2 = Character("[w_name]", color="#c579fc", what_color="#fff", what_outlines=[(2, "#7732bc", 0, 0)], image="w2_img")
    define m1 = Character("", color="#c579fc", what_color="#fff", what_outlines=[(0.5, "#7732bc", 0, 0)])
    define du = Character("", color="#ffaddb", what_color="#fff", what_outlines=[(0.5, "#b77c9e", 0, 0)])
    define sk = Character("Skeleton", color="#fff", what_color="#fff", image="sk_img")
    define k = Character ("Karen", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)], image="k_img")
    define k2 = Character ("", color="#d13cb8", what_color="#fff", what_outlines=[(0.5, "#5b1850", 0, 0)])
    define g1 = Character ("Ghoulish Girl", color="#bcddff", what_color="#fff", what_outlines=[(0.5, "#3c4651", 0, 0)], image="g1_img")
    define g2 = Character ("Jawsome Girl", color="#d1a22e", what_color="#fff", what_outlines=[(0.5, "#564313", 0, 0)], image="g2_img")

    # blah, blah, more character definitions...

# somewhere else in the code... (doesn't really matter that much where)...
image side ps_img = "side_ps.png"
image side m_img = "side_m.png"
image side x_img = "side_x.png"
image side f_img = "side_f.png"
image side pf_img = "side_pf.png"
image side d_img = "side_d.png"
image side w_img = "side_w.png"
image side s_img = "side_s.png"
image side a_img = "side_a.png"
image side l_img = "side_l.png"
image side n_img = "side_n.png"
image side q_img = "side_q.png"
image side w2_img = "side_w2.png"

image side sk_img = "side_sk.png"
image side k_img = "side_k.png"
image side g1_img = "side_g1.png"
image side g2_img = "side_g2.png"
image side r_img = "side_r.png"
image side o_img = "side_o.png"
image side h_img = "side_h.png"

# blah, blah, more side images...

In my example, I've chosen not to add image= to every character (ignoring the ones that have blank names). I've only done so to demonstrate that you don't need to have a side image for every speaking character.

Likewise the naming of the actual filenames is a personal choice to keep with the naming convention I've already decided upon. I could have named them anything, but following the same pattern made more sense to me.

I hope that's enough detail to cover all eventualities.
thank you