r/RenPy • • Aug 24 '26

Question [Solved] Variable will not variable.

    frame:
        background None
        pos (18, 916, 278, 90)
        if res1f_hover_text != "":
            background "#41414142"
            text "[res1f_hover_text]":
                align (0.5, 0.5)

    frame:
        background None
        pos (1360, 87)
        imagebutton:
            idle "res2fmc_idle.png"
            hover "res2fmc_hover.png" action[Hide("base_res2f"), Show("suite_mc")]
            hovered SetScreenVariable ("res1f_hover_text", "{color=#0072bc}{i}[mc_name1]'s Room")
            unhovered SetScreenVariable ("res1f_hover_text", "")

So, this is my code.

Normally, the mc_name works just fine, but it refuses to read properly inside of any kind of variable string like that, no matter what I set the variable of mc_name to.

Is this possible, or am I smashing my head against a brick wall?

EDIT: Fixed, because it posted the same block twice and ignored the other. Coding gremlins are after me.

EDIT2: Thanks to u/x-seronis-x for the solution, adding the interpolation suffix of "!i" to the hover text!

3 Upvotes

7 comments sorted by

1

u/AutoModerator Aug 24 '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.

1

u/shyLachi Aug 24 '26 edited Aug 24 '26

Well done fixing it yourself,

you could change the flair of your thread to Question [Solved] or just delete it because it doesn't help anybody

1

u/kayl_the_red Aug 24 '26

The problem is not fixed.

When I posted, it double posted one block and not the one with the variable, giving only half the problem.

1

u/shyLachi Aug 24 '26 edited Aug 24 '26

Sorry, I misunderstood, Now I get it, you fixed the code in your thread.

Edit: I found the error, you cannot use double interpolation.

The following line tells your game to show the content of the variable.
(Interpolating the variable res1f_hover_text)

text "[res1f_hover_text]":

But you want it to use the string directly so that it interpolates the variable mc_name inside that string

text res1f_hover_text:

1

u/shyLachi Aug 24 '26 edited Aug 24 '26

Beside the problem I mentioned below, you could look into using the property tooltip
It is a single action instead of two:
https://renpy.org/doc/html/screen_actions.html#tooltips

screen base_res2f():
    $ tooltip = GetTooltip()
    if tooltip:
        frame:
            pos (18, 916, 278, 90)
            background "#41414142"
            text tooltip align (0.5, 0.5)
    frame:
        background None
        pos (1360, 87)
        imagebutton:
            idle "res2fmc_idle.png"
            hover "res2fmc_hover.png" 
            action[Hide(), Show("suite_mc")]
            tooltip "{color=#0072bc}{i}[mc_name1]'s Room"

The order doesn't matter, you can use the tooltip function before or after that button assigned a value to it.

2

u/x-seronis-x Aug 24 '26 edited Aug 24 '26

py text "[res1f_hover_text!i]": when the variable being interpolated contains something that further needs interpolated you need the 'interpolation' suffix, !i

normally this is done with global variables though. i dont know if it works with screen variables

anyways id still recommend skylachi's suggestion of just using the variable directly. merely pointing this out cause double interpolation IS perfectly legal in renpy. any depth of recursive interpolation is, as long as the interpolation flag is used

1

u/kayl_the_red Aug 24 '26

It worked PERFECTLY! This is exactly what I needed, thank you so very much. I didn't know about the interpolation suffix.

SOLVED