Ren'Py Help with using tooltips

SPkiller31

Professional Degenerate
Game Developer
Dec 20, 2020
138
182
Hi,

I'm trying to change choice menus when visiting characters with icons that will show whether or not that character has new content.
I think that the best option is using Tooltips/Nearrect for that but I'm kinda dumb.
(I suspect it's something obvious that I've missed but the tooltip section for Renpy looks a bit barebones without different scenario examples.)

What I'm trying to achieve: I have few imagebuttons, in this case: doors, leading to 5 different rooms and when hovered each would display two character icons.
Each character has either an their icon AND exclamation mark or just their icon depending on if there's new content for them. So displayed png changes depending on the state of where player is in the game.

+/- Example of what I mean(The same imagebutton, leading to the exact same place, tooltip changing depending on player progression):
Python:
if test_flag1 == False:
    imagebutton xalign 0.5 yalign 0.5:
        focus_mask True
        idle "door1_idle"
        hover "door1_hover"
        tooltip (#Value here)                               
        action Jump("room1")#Leads to label that divides to  character 1 or 2, not sure if there's way to display choice menu with imagebutton
        $ tt = GetTooltip()
        if tt:
               add "images/character1_exclamation.png" xpos 300 ypos 100
               add "images/character2.exclamation.png" xpos 300 ypos 350
#For pure example, both characters have new content because of the same flag
#Because of that, I display version of their icons with "!" sign added
else:
    imagebutton xalign 0.5 yalign 0.5:
        focus_mask True
        idle "door1_idle"
        hover "door1_hover"
        tooltip (#Value here)                               
        action Jump("room1") #Same way, leads to the label that checks flag and lets the player choose who to visit
        $ tt = GetTooltip()
        if tt:
               #In this case I want characters to have basic icon as there's nothing new to see, something like:
               #add "images/character1.png" xpos 300 ypos 350
               #add "images/character2.png" xpos 300 ypos 350
####################
#Another imagebutton at different location, depending on different flags
####################

I'm having problems when trying to add more flags and rooms that use tooltips the same way, at the same time.
(Different imagebuttons at a different position would need tooltips to be shown next to that door, not at the set pos.)

AFAIK I can't define multiple variables that way, like: $ tt_1, $ tt_2 etc. or put multiple tooltips inside single imagebutton.
I probably don't understand the basics but I'm not sure how to display multiple tooltips that would depend on different flags as currently, every icon gets copied and shows the same thing.
Given the fact that there'll be multiple doors, that will check for both characters and their variables, I'm trying to make as little mess in code as possible as there'll be a lot of text.

I know that there are at least 2 braindead workarounds: Either using "hovered" or creating a "hover" version of imagebutton with every outcome possible: Door with icon, door with icon and "!" baked into png etc. but that would be quite ugly code-wise and require a ton of if/else.

Big thanks if someone knows the most elegant solution and is willing to explain it like talking to a toddler.
 
Last edited: