Make imagebuttons unclickable under choice menus

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Gigan
Newbie
Posts: 13
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Make imagebuttons unclickable under choice menus

#1 Post by Gigan » Wed Jun 01, 2022 8:40 pm

Hello everyone ! Sorry for bothering you again but I have 0 idea on how to fix that problem. :/

I have a shop screen with several clickable imagebuttons (only the diary here, and the "back" one) :
Image

When you click on a item, a choice menu appear :
Image

The problem is the action won't be completed if when clicking on the "Yeah" option, the mouse cursor is still on the imagebutton. The first and second screens just repeat themselves until I click somewhere else. Only then, the purchase is deemed completed and the item disappear from the shelves.

Any way to correct that problem ? Like, by making the imagebutton unclickable when a choice menu appear ? :/

My code, for what it's worth :

Code: Select all

screen magasin_hotspot():
    add "bg/bg magasin_vente.png"
    add "candiceshop" at right
    add "candiceshop_eye neutre" at right
    add "candiceshop_mouth parle" at right
    imagebutton: #Bouton retour
        focus_mask True
        xpos 10
        ypos 400
        idle "imagebutton_retour.png"
        action [Hide("magasin_hotspot"), Jump("shop_1_choix")]
    if diary_shop == True: #diary
        imagebutton:
            focus_mask True
            xpos 400
            ypos 40
            idle "diary_icon.png"
            action Jump("diary_conv")

Code: Select all

label shop_buy:
    show screen magasin_hotspot
    show screen money_display
    c "Take your time."

label diary_conv:
    menu:
        c "An old diary. Found it on the floor. Most of the pages are torn, but heh. Selling it anyway... 100 Gold."
        "Yeah":
            if money_points >= 100:
                c "Thank you !"
                play sound "audio/jingle_tresor2.wav"
                d "{color=#ad2c05}{font=fonts/BaksoSapi.otf}{size=+8}You got a diary !{/size}{/font}\nWhat it is all about...{/color}"
                $ diary_shop = False
                $ money_points -= 100
                $ got_diary = True
                $ got_diary_shop = True
                $ first_time_diary = True
                $ first_time_diary_buffalo = True
                jump shop_buy
            else:
                c "You don't have enough money, you doofus !"
                jump shop_buy
        "no":
            c "Alright."
            jump shop_buy

User avatar
niho
Newbie
Posts: 17
Joined: Fri Apr 15, 2022 11:31 pm
itch: nihomi
Discord: niho#0953
Contact:

Re: Make imagebuttons unclickable under choice menus

#2 Post by niho » Thu Jun 02, 2022 12:05 am

A simple way to enable/disable buttons is by using sensitive. You can either give it a true/false statement or a flag, so that the button is only enabled when its flag is true. For example you could add sensitive buttons_enabled to every button that you want to be disabled at some point, so then you can just add the following to your labels:

Code: Select all

label shop_buy:
    $ buttons_enabled = True
    ...

label diary_conv:
    $ buttons_enabled = False
    ...
    
And you shouldn't be able to click the other buttons.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Make imagebuttons unclickable under choice menus

#3 Post by Ocelot » Thu Jun 02, 2022 4:32 am

modes were made for that.

Code: Select all

screen scr():
    $ in_menu = (renpy.get_mode() == 'menu')
    # . . .
    buttton:
        sensitive not in_menu
        
< < insert Rick Cook quote here > >

Gigan
Newbie
Posts: 13
Joined: Mon Jan 10, 2022 7:02 pm
Contact:

Re: Make imagebuttons unclickable under choice menus

#4 Post by Gigan » Thu Jun 02, 2022 5:07 am

Well that was easier than expected. :|
Thank you so much to both of you ! ( >^_^)>

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], _ticlock_