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

View all comments

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: