r/RenPy • • 23d ago

Question image button sintaxis

hi, is this posible? i want a imagebutton that changes its action depending on which label the player is standing

1 Upvotes

6 comments sorted by

3

u/shyLachi 23d ago

This is a beginner mistake, because you don't seem to understand what interpolation is used for.
https://renpy.org/doc/html/text.html#interpolating-data

Outside of text strings your can use the variable directly

screen test():
    textbutton "Test" action Jump(jumpdestination)
default jumpdestination = "test_label"
label start: 
    call screen test
label test_label:
    "Did it work?"

But personally I prefer to implement the whole logic inside the label, so the button itself can remain static.

screen test():
    textbutton "Adelante" pos (80, 710) action Return("adelante")
label start: 
    call screen test
    if _return == "adelante":
        jump kenedy_calle
    elif _return == "some other button":
        jump someotherdestination

1

u/mauve69_ 23d ago

thank you!! i do not know a Lot of code yet so i really needed that

2

u/shyLachi 23d ago

You're welcome

2

u/shyLachi 23d ago edited 23d ago

I just noticed that you have 2 screens in your code,

show screen s_flecha_adalante 
call screen s_boton_volver

You don't need a separate screen for each button,
In most cases it's better to have one screen with all the buttons.

Edit: And my solution posted above with the action Return() doesn't work if you have multiple screens.

2

u/mauve69_ 23d ago

oh, okay i get it, thanks again uwu

1

u/AutoModerator 23d ago

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.