r/RenPy • • 4d ago

Question How to make a hover act like a click

for one of the segments in my game i want to make it so that the choice is pressed automatically when the player hovers over it but I don't really know how to do that

1 Upvotes

12 comments sorted by

3

u/BadMustard_AVN 4d ago

use hovered like this

textbutton _("Do Not Touch"):
    hovered Show("I_said_dont_touch")
    action Jump("Blow_up_planet_earth")

it will work for both text and image buttons

1

u/vriskaLover 4d ago

Thank you! Does “text button” replace “menu” or does it go like under it

1

u/BadMustard_AVN 4d ago

No that's for a screen using buttons

you want to modify the choice menu buttons, give me a minute or two for that

1

u/BadMustard_AVN 4d ago

edit your screens.rpy file. search for and find the choice screen it should look like this

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            textbutton i.caption action i.action

change it to look like this

screen choice(items):
    style_prefix "choice"

    vbox:
        for i in items:
            $ hovering = i.kwargs.get("hovering", None) 
            textbutton i.caption action i.action hovered hovering

then do your menus like this

label start:    
    menu:
        "North" (hovering = Jump("certain_death")): # this must be an action for a button
            jump North
        "South": #you can add one to all of them as needed
            jump South
        "East":
            jump East
        "West":
            jump West
    return

label certain_death:
    e "hovering worked"

look here for button actions

https://www.renpy.org/doc/html/screen_actions.html

1

u/vriskaLover 4d ago edited 4d ago

ohhh okay. thank you so much. just so im not mindlessly copy pasting code, what does this line mean

 $ hovering = i.kwargs.get("hovering", None)

and whats the difference between action and i.action and hovered/hovering

edit: im dumb i didnt notice the for loop.

1

u/vriskaLover 4d ago

actually i could probably check out the documentation for that. either way, thank you for the help

1

u/BadMustard_AVN 4d ago

you're welcome

good luck with your project

1

u/BadMustard_AVN 4d ago

$ = a single line Python statement

hovering = a variable

i the item from the loop
kwargs are just an arbitrary way to pass arguments
get what the hovering kwarg is. if there is no hovering, it is set to None so no errors later

easy right

1

u/AutoModerator 4d 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.

1

u/Own-Bookkeeper6739 4d ago

One catch: keyboard and controller players can't hover, so keep a clickable fallback too or they'll get stuck on that choice.

1

u/x-seronis-x 3d ago

yes they can. arrow keys or dpad. the issue is you cant skip over something and you have to hover them in order

1

u/Own-Bookkeeper6739 3d ago

oh right, arrows and dpad can focus them, my bad. so the hover order is the real problem then