Ren'Py Images Won't Always Change

Kalloway

New Member
Game Developer
Aug 24, 2018
12
142
Hello all!

I am attempting to create a game in Ren'py, but I am having an issue with images sometimes not switching when they should. For instance, in my code:


Code:
show dtalklaugh2
d "Oh man, your face right now! I'm sorry, that was just too funny."
m "Oh phew. Thank god you were joking. It would have been really awkward if we were {i}both{/i} serial killers."

show dtalksad2
d "..."

show dtalklaugh2
d "Dammit! I tried so hard to keep a straight face!"
The first switch between dtalklaugh2 and dtalksad2 occurs no problem, but the switch back from sad2 to laugh2 doesn't occur. This isn't the only instance that this kind of thing happens. I try to make it look like an actual conversation, so there's often a lot of switching between the girls mouth being open and closed, but the switches don't occur as intended. Same story if I switch to Scene instead of Show.

I searched the threads but didn't find anything that quite fit the problem I was having. I am entirely new to this kind of thing, so it is very possible the issue is pretty obvious and I'm just a dunce, though I keep the Ren'py documentation open at all times.

Screenshots attached coincide with the code above, so you can see the switch happening and then not happening. I know the scene isn't fantastic, I'm still trying to get a handle on everything.

Can anyone tell me how to fix this?

Thanks for the help!
 

Erogrey

New Member
May 20, 2019
8
6
Hi. You can't show the same image twice without "doing" with that image something. Hide the first one or use "AS":

Python:
    show first_i
    "first_i"
    show second_i
    "second_i"
    show first_i as first_i2
    "first_i"
 

Kalloway

New Member
Game Developer
Aug 24, 2018
12
142
Huh, could have sworn I tried that, but apparently not. Switched all instances of show over to scene and it all appears to be working now. Thanks for the help!
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,583
2,223
Can anyone tell me how to fix this?
As others have already said, you need to use instead of .
Maybe start using transitions too, for good measure.

Python:
scene dtalklaugh2 with fade
d "Oh man, your face right now! I'm sorry, that was just too funny."
m "Oh phew. Thank god you were joking. It would have been really awkward if we were {i}both{/i} serial killers."

scene dtalksad2 with dissolve
d "..."

scene dtalklaugh2 with dissolve
d "Dammit! I tried so hard to keep a straight face!"

But I thought it would also be worth explaining WHY you're having problems.

RenPy has a tagging system for various things. If something has the same tag, only one of those things can be shown at once. You see it occasionally in screen definitions, where you might have pages in a codex or a collection of phone images for showing different people or anything else you can think of.

Where that matters to you is that images are automatically tagged with the first part of their name. So dtalklaugh2.jpg is tagged dtalklaugh2, etc.
It makes more sense when you have things like background images or foreground sprites for characters. Where the first part of the name is picked up as its tag.

Python:
image bg room1 = room1_background.jpg     # the .jpg .png aren't really needed, but I'm including them here to expand the example.
image bg room2 = room2_background.jpg
image bg room3 = backg_room3.png

image eileen whitedress smiling = eileen_smiling_whitedress.png
image eileen jeans grumpy = eileen_jeans_grumpy.png

In this case, there are two tags... bg and eileen

Showing a second image with the same tag, just replaces the first. So showing Eileen wearing jeans would replace any previous shown sprite of any other Eileen image.

Where this matters to you is that you've used dtalklaugh2, dtalksad2 and dtalklaugh2. Which despite being 3 show commands, is actually only 2 tagged images.

So what happens is that dtalklaugh2 is shown on the screen. Then dtalksad2 is shown. Because it's tagged differently, it's just displayed over the top of the previous image. I'm betting that they're full screen images, and as a result, you can't see the first one after the second one appears - but it's still there, behind the first. Then comes your third show command. RenPy looks at it, as realizes it's already showing that same tagged image on the screen and either replaces the same image on the same layer (ie. behind your 2nd image) or decides that for performance reasons, doesn't need to redisplay an image it already knows is on screen (even if you can't see it).

The end result is that the 3rd show command doesn't seem to do anything, because it's effectively replaced dtalklaugh2 with dtalklaugh2 on a layer you can't see because dtalksad2 is in your way.

scene on the other hand clears the UI before showing the named displayable. Removing all previously shown images and starting a new scene.

And if you're ever wondering... "what's the worst the can happen?"... go read this thread, where the developer only used show and by the point the game was showing 300+ images on the screen at the same time (each hidden behind one another), the game ground to a halt and caused the saved game data to crap itself.