A quick question

Script_Patreon

New Member
Jul 31, 2022
5
1
I have 4 image buttons

1662162409537.png


I want to make it so that when you press one of these buttons it shows an image, but it does NOT jump from the label, because otherwise I think it could be complicated.

How would it be possible to display an image when clicking on the button and when the player clicked on the screen or another button that I later added, it returned to the same position it was in before (I mean the text to the screen, etc) as if time had not advanced
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,964
16,209
I have 4 image buttons
The () is missing for all screen declarations.
As said by , their absence "requires Ren'Py to be more conservative when analyzing the screen, which can limit the optimization it performs".

Why a screen by button ?
It clearly over complicate the code since you've to show/hide many screens every time, and also can't call them.

Why xanchor/yanchor in addition with xpos/ypos ?
The anchor are just adjusting the position you gave. You're positioning the button, then telling Ren'Py to change this position by half its width and half its height. Just position the button directly.
Anchors are for very specific cases. Mostly when you're dealing with multi elements displayable (fixed, label or textbutton) and have to modify the position of the embedded one.

Why action Show "statusd.png" ?
documentation is relatively explicit, "this causes another screen to be shown". And obviously, it don't works because... well, where are the parenthesis ?

There's not much right in the few lines of code you shown.


I want to make it so that when you press one of these buttons it shows an image, but it does NOT jump from the label, because otherwise I think it could be complicated.
One of the many way to do this:
Python:
screen whatever():

    default shown = None

    if not shown is None:
        add shown xalign 0.5 yalign 0.5

    imagebutton:
        [positioning]
        auto "whatever%s.png"
        action SetScreenVariable( "shown", "whatever image.jpg" )

    imagebutton:
        [positioning]
        auto "whatever1%s.png"
        action SetScreenVariable( "shown", "whatever1 image.jpg" )

How would it be possible to display an image when clicking on the button and when the player clicked on the screen or another button that I later added, it returned to the same position it was in before (I mean the text to the screen, etc) as if time had not advanced
It's what is for.
Python:
screen whatever():

    [...]

    textbutton "Close" action Return()

label whatever:
    call screen whatever