How to update image favor screens over time [SOLVED]

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
kedta35
Regular
Posts: 50
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

How to update image favor screens over time [SOLVED]

#1 Post by kedta35 »

I'm trying to create a system for updating character favor screens with different images based on the choices players make throughout the game. Below is my code for the favor screens. Just to explain a little about the favor screens in case it looks a little odd, char2 has a favor screen which shows the favor between char2 and multiple different characters which you can click on to see the specifics. Char3 has 1 image as their favor screen.

Code: Select all

screen sidebuttons():
    imagemap:
        idle "images/favorscreens/favorbuttons idle.png"
        hover "images/favorscreens/favorbuttons hover.png"
        hotspot (1827, 555, 121, 128) action [Hide(""), Show("char2_favor_screen")]
        hotspot (1828, 686, 116, 129) action [Hide(""), Show("char3_favor_screen")]

screen char2_favor_screen:
    add "images/favorscreens/char2favorscreen base.png" align (.5,.5)
    modal True
    imagemap:
        idle "images/favorscreens/char2favorscreen char1 idle.png"
        hover "images/favorscreens/char2favorscreen char1 hover.png"
        hotspot (18, 3, 390, 480) action [Hide("char2favorscreen base.png"), Show("char1_char2_favor")]

screen char1_char2_favor:
    add "images/scenea3.png"
    imagemap:
        idle "images/favorscreens/char1favorbutton idle.png"
        hover "images/favorscreens/char1favorbutton hover.png"
        hotspot (1746, 608, 175, 186) action [Hide("char1_char2_favor"), Hide("char2_favor_screen")] 

screen char3_favor_screen:
    add "images/scenea4.png"
    modal True
    imagemap:
        idle "images/favorscreens/char1favorbutton idle.png"
        hover "images/favorscreens/char1favorbutton hover.png"
        hotspot (1746, 608, 175, 186) action [Hide("char3_favor_screen")]
I want to make it so that, as the player progresses through the story and makes different choices, the images displayed in the favor screens for different characters change accordingly. For instance, as the relationship with char2 and char1 changes for the worse or better, I'd like to update "char1_char2_favor" with a different image.
I would like to use variables that track each characters favor but I've seen like 3 different ways to write that and I don't know which to use nor how to implement them into this context.
Please let me know the most efficient way to do this if anyone knows and cares enough to explain.
Thanks in advance.
Last edited by kedta35 on Mon Sep 04, 2023 6:40 am, edited 1 time in total.

Misamor98
Regular
Posts: 45
Joined: Wed Jul 14, 2021 4:43 pm
Contact:

Re: How to update image favor screens over time

#2 Post by Misamor98 »

I don't get what your "char1_char2_favor" screen does, all I see is a button to hide the screen and show an other.
If I were to make a screen showing different favor levels, I'd use the "add" statement and use string interpolation to update it accordingly, like so:

Code: Select all

default char1_char2_favorlvl = 0

screen char1_char2_favor:
    add "images/favorlvls/char1_char2_favorlvl" + str(char1_char2_favorlvl) + ".png"
Of course this would require a naming convention like this for your images:
images/favorlvls/char1_char2_favorlvl1.png for favor lvl 1 between char 1 and char2
images/favorlvls/char1_char2_favorlvl2.png for favor lvl 2 between char 1 and char2...
Update your char1_char2_favorlvl variable along your story, and the add statement will always show the right favor lvl

I hope this answers your question

kedta35
Regular
Posts: 50
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

Re: How to update image favor screens over time

#3 Post by kedta35 »

In that context, what would be the code to change the favor level either with options or just throughout the game?

Misamor98
Regular
Posts: 45
Joined: Wed Jul 14, 2021 4:43 pm
Contact:

Re: How to update image favor screens over time

#4 Post by Misamor98 »

I'm guessing you're making a VN, so a basic

Code: Select all

$ char1_char2_favorlvl = 1
between 2 lines of code.

I will just add that all of this seems like basic ren'py stuff. I would suggest you to go through the ren'py tutorial before continuing.
Just lauch the "Tutorial" project that comes with the Ren'py launcher.

kedta35
Regular
Posts: 50
Joined: Wed Aug 30, 2023 1:31 pm
Contact:

Re: How to update image favor screens over time

#5 Post by kedta35 »

Thanks a bunch, I was stuck for a while because I'm still really new to this. I tweaked it a little and it's perfect for what I wanted.

Code: Select all

    add "images/favorscreens/char1char2" + str(char1_char2_favor) + ".png"
When I wrote the code like this it makes it so that it shows an image named "char1char2(favor number).png" so like "char1char2100.png". This way you won't need to make the names for the images too complicated.

Post Reply

Who is online

Users browsing this forum: decocloud, Google [Bot], Ocelot