Ren'Py Unclickable Buttons

keptyouhanging

New Member
Dec 29, 2016
3
1
I've seen this in plenty of games but now that I'm working with ren'py for the first time I can't find a way to do this. Basically when theres multiple choices to select from and one has a condition, say, it requires lust to be >40, I want that button to be visible but grayed out and unclickable. If I add a condition to the choice and it's not met that choice will just disappear.
So yeah, how can I make an unclickable button?
 
  • Like
Reactions: Palanto

Potato

Member
Oct 15, 2016
249
437
I've seen this in plenty of games but now that I'm working with ren'py for the first time I can't find a way to do this. Basically when theres multiple choices to select from and one has a condition, say, it requires lust to be >40, I want that button to be visible but grayed out and unclickable. If I add a condition to the choice and it's not met that choice will just disappear.
So yeah, how can I make an unclickable button?
if variable > 40:
menu: button text
 

RandomUser5546

New Member
Jul 23, 2017
14
19
Won't be unclickable but it'll achieve a similar result:

Stick a label immediately before the menu, then have two entries for the button you wish to have unclickable, one is the normal one for if the condition is met which does whatever you want it to and the second should only appear if the condition is not met and just has a jump back to the label which shows the menu again.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
Are you talking about the "choice" statement, or about textbutton/imagebutton ?
In the second case, the answer gave by @DSSAlex will work, but in the first case you'll have to do more works and edit the "choice" screen.
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
screens.rpy
Code:
screen choice(items):
    window:
        style "window"
        xalign 0.5
        yalign 0.5
        background None

        vbox:
            style "vbox"
            xalign 0.5
            spacing 2

            for caption, action, chosen in items:

                ## add an hbox so the image and button show up side-by-side.
                hbox:
                    # disabled
                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")

                        if action:
                            button:
                                action None
                                style "choice_button"
                                text caption style "choice_button_text"
                        else:
                            text caption style "choice_button_text"

                    # normal
                    else:
                        if action:
                            button:
                                action action
                                style "choice_button"
                                text caption style "choice_button_text"
                        else:
                            text caption style "choice_button_text"
Then a choice menu should look like this:

script.rpy (Or whereever in your game)
Code:
menu nameOfMenu:
    "This is the grayed out first choice (disabled)" if whatEverStatIsToLow < 10:
    "This is the same first choice but not grayed out" if whatEverStatIsHighEnough >= 10:
        jump labelName
    "This is the second choice grayed out (disabled)" if not whatEverOtherStatIsFalse:
    "This is the second choice not grayed out" if whatEverOtherStatIsTrue:
        jump labelName
Or in your case:
Code:
menu LustMenu:
    "Oh god I want her right now! (disabled)" if lust <= 40:
    "Oh god I want her right now!" if lust > 40:
        jump take_Her
    "Nah, not interested! (disabled)" if lust > 40:
    "Nah, not interested!" if lust <= 40:
        jump not_interested
Meaning: Everytime you add " (disabled)" (Don't forget the space between the text and the (disabled) ) it get's grayed out....


p.S.: Hope that helps, edited a choice screen that adds "images" left and right of the choice for that. So you wouldn't really need the hbox but it doesn't hurt either way ;)
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
Won't be unclickable but it'll achieve a similar result:

Stick a label immediately before the menu, then have two entries for the button you wish to have unclickable, one is the normal one for if the condition is met which does whatever you want it to and the second should only appear if the condition is not met and just has a jump back to the label which shows the menu again.
Ooops only read that now...
You don't need to put a label "before" the menu, you can just jump to the start of the menu itself:
Code:
menu NameOfTheMenu:
    "I want to start the menu again":
        jump NameOfTheMenu
    "I don't want to see this damn menu anymore!":
        jump NextLabelName
With "NameOfTheMenu" you give the menu it's own label.
 
  • Like
Reactions: Vanderer

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,236
You don't need to put a label "before" the menu, you can just jump to the start of the menu itself:
You can also use a while loop:
Code:
label someLabel:
    [blablabla whatever code you want]
    while True:
        menu:
            "I want to stay here":
                 "Alright, you'll stay here."
                 "After all, being stuck in a loop can be useful sometimes."
            "Alright, I'll go somewhere else":
                 "Ready..."
                 "Set..."
                 "Go..."
                 jump anotherLabel

label anotherLabel:
   [blablabla whatever code you want]
 
  • Like
Reactions: Palanto

RidiculAwsome

Newbie
Feb 12, 2019
23
443
screens.rpy
Code:
screen choice(items):
    window:
        style "window"
        xalign 0.5
        yalign 0.5
        background None

        vbox:
            style "vbox"
            xalign 0.5
            spacing 2

            for caption, action, chosen in items:

                ## add an hbox so the image and button show up side-by-side.
                hbox:
                    # disabled
                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "")

                        if action:
                            button:
                                action None
                                style "choice_button"
                                text caption style "choice_button_text"
                        else:
                            text caption style "choice_button_text"

                    # normal
                    else:
                        if action:
                            button:
                                action action
                                style "choice_button"
                                text caption style "choice_button_text"
                        else:
                            text caption style "choice_button_text"
Then a choice menu should look like this:

script.rpy (Or whereever in your game)
Code:
menu nameOfMenu:
    "This is the grayed out first choice (disabled)" if whatEverStatIsToLow < 10:
    "This is the same first choice but not grayed out" if whatEverStatIsHighEnough >= 10:
        jump labelName
    "This is the second choice grayed out (disabled)" if not whatEverOtherStatIsFalse:
    "This is the second choice not grayed out" if whatEverOtherStatIsTrue:
        jump labelName
Or in your case:
Code:
menu LustMenu:
    "Oh god I want her right now! (disabled)" if lust <= 40:
    "Oh god I want her right now!" if lust > 40:
        jump take_Her
    "Nah, not interested! (disabled)" if lust > 40:
    "Nah, not interested!" if lust <= 40:
        jump not_interested
Meaning: Everytime you add " (disabled)" (Don't forget the space between the text and the (disabled) ) it get's grayed out....


p.S.: Hope that helps, edited a choice screen that adds "images" left and right of the choice for that. So you wouldn't really need the hbox but it doesn't hurt either way ;)
I've tried this and disabled funciton works fine but, when the conditon doesn't met, that menu choice just dissappear.
 
  • Like
Reactions: Iskender

KiaAzad

Member
Feb 27, 2019
291
214
Add this line somewhere (maybe your options.rpy file)
Python:
define config.menu_include_disabled = True
then use your usual conditions to disable your options:

Python:
menu:
    "Do it":
        jump demo_it
    "Don't do it" if cant_do_it:
        jump I_cant
 
  • Like
Reactions: RNGeusEX