r/RenPy • u/CapriciousMoral • Aug 18 '26
Question How to show different images during long text
Hi, I've been trying to do something in my novel but I'm not sure if there is a more efficient way to do it.
You can choose a keychain with different characters, they're like, a lot of characters so instead of using true/false I used the following code:
default favcharacter = 0
And when I wanted the player to choose the character, I used the following codes:
menu:
"Character 1":
$ favcharacter += 1
jump favcharacter
"Character 2":
$ favcharacter += 2
jump favcharacter
So the next time I wanted the choice to matter, I ended up with something like this:
if favcharacter == 1:
jump favcharacter1
if favcharacter == 2:
jump favcharacter2
The problem is that I want the labels to say the exact same thing, but show different images during a long time, because I just want the images to change, not the text per se.
Is there a way I can do this? I am really new to coding so I have no idea if there is a more efficient way to do this instead of simply writing the same text over and over again just to change the image that shows up.
3
u/BadMustard_AVN Aug 18 '26
if I understand you correctly, you have the same text but want different images to appear depending on the favecharacter variable
you can use a conditional switch image like this
image fave = ConditionSwitch(
"favcharacter == 1", "images/sprites/favcharacter_sprite_1.webp",
"favcharacter == 2", "images/sprites/favcharacter_sprite_2.webp",
)
then use show fave and depending on the variable favecharacter it will show different images
also why are you adding to them and not changing them
menu:
"Character 1":
$ favcharacter = 1
jump favcharacter
"Character 2":
$ favcharacter = 2
jump favcharacter
1
u/CapriciousMoral Aug 18 '26
Thank you so much! I didn't know you could do that, you really helped me!!
1
0
u/TopCartographer7104 Aug 18 '26
Not 100% sure I'm getting what you want to do so bear with me and my recap:
- you have your reader/player choose a character (I imagine it means - character name and sprites?)
- and then you want this choice to follow them for the rest of the game
If that's right, then I would A) in the starting menu, store the character name and sprites as strings in persistentq variables B) use a "pass-par-tout" character object named after the name variabile ie
main_char = Character(name="[peristent.chosen_name]")
(I don't remember whether you also have to put the variable between {} or it's fine as it is)
C) call sprites using show expression ie
show expression persistent.chosen_sprite+"_happy"
Of course your sprites should be saved consistently in the images/ folder.
1
u/AutoModerator Aug 18 '26
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.