Ren'Py Make text in menu insensitive

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
Hello, I'm trying to create a menu which would enable the player to see that he indeed missed a choice there, instead of the 1 showing choice. I have this menu at the moment but it's uses the annoying getting back to the menu till he doesn't click the correct choice.

label choices
menu:
"choice 1": (always seeable)
"choice" if p == 2:
"{color=#999999}?????{/color}" p <=1:
jump choices

I know about the existance of -> define config.menu_include_disabled = True
with setting colour to grey with -> define gui.choice_button_text_insensitive_color = "#555"
but I don't want the player to see the other possible choice's text at all if not met the requirement. I would much prefer the "?????". Is there any work around this?

I've tried to alter the choice screen but It didn't work out.
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,098
3,349
If you are already using the define config.menu_include_disabled = True setting...

You could use the same logic check as you have for the menu item to set alternate text in a variable which is used for the button text.

Code:
label ask_hot_girl_to_prom:

    if p < 2:
        choice2_text = "?????"
    else
        choice2_text = "Do a breakdancing move to win her heart"
        
    menu:
        "She's about to walk away from you, what are you going to do?"
        
        "Hang your head and say nothing like a beta":
            "Ugh, I literally can't even."
            jump you_are_a_loser

        "[choice2_text]" if p >= 2:
            "Her eyes light up! She begins robot dancing and then kisses you."
            jump fortnite_victory_emote
 

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
If you are already using the define config.menu_include_disabled = True setting...

You could use the same logic check as you have for the menu item to set alternate text in a variable which is used for the button text.

Code:
label ask_hot_girl_to_prom:

    if p < 2:
        choice2_text = "?????"
    else
        choice2_text = "Do a breakdancing move to win her heart"
       
    menu:
        "She's about to walk away from you, what are you going to do?"
       
        "Hang your head and say nothing like a beta":
            "Ugh, I literally can't even."
            jump you_are_a_loser

        "[choice2_text]" if p >= 2:
            "Her eyes light up! She begins robot dancing and then kisses you."
            jump fortnite_victory_emote
Thanks, I'm really dummy in coding. Now I'm into another error, when I use this on my code it comes back with an error:/
File "game/script.rpy", line 1128: expected statement.
choice2_text = "?????"
^

I assume I can't just magically put the if & else anywhere I would like to? I did create a label as well just specifically for this menu as well.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,557
2,170
This thread may help you...
https://f95zone.to/threads/greying-out-choices-that-dont-meet-requirements.55499/

That thread is about having menu items which can't be picked, but is still shown (enabled/disabled as needed).

Menu choices can include if style checks, but not if / else.

I have a vague idea that another thread had an improved version of this solution. But I couldn't' find it as quickly as I could find this one.
 
Last edited:
  • Like
Reactions: 3DeadAngel

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
This thread may help you...
https://f95zone.to/threads/greying-out-choices-that-dont-meet-requirements.55499/

That thread is about having menu items which can't be picked, but is still shown (enabled/disabled as needed).

Menu choices can include if style checks, but not if / else.

I have a vague idea that another thread had an improved version of this solution. But I couldn't' find it as quickly as I could find this one.
Yup this was the post where I tried first your method of solving it. (Which doesnt work for me:/).

menu:
"choice":
"choice2" if p==4 and m==1:
"??????" if p<=3 and m<=0 (enabled=True is False):
pass

This is how I implemnted the code. And yes I altered the screen choice.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,557
2,170
Yup this was the post where I tried first your method of solving it. (Which doesnt work for me:/).
...snip...
This is how I implemented the code. And yes I altered the screen choice.

Ah ha.

The (enabled=xxx) code would usually be a replacement for the if. You can have both, but it wouldn't make sense in my opinion.

if will either show or not show the menu choice (by default anyway - you already know about config.menu_include_disabled = True)

The changes to the screen choices: screen to check for kwargs, etc. is what makes the enabled control whether the option is sensitive or insensitive to user interactions.

Assuming all the changes from the other thread, I think what you are wanting is more like :

Python:
    menu:
        "choice":
            "I picked choice1"

        "choice2" (enabled=p==4 and m==1):
            "I picked choice2"

        "choice3" (enabled=p<=3 and m<=0):
            "I picked choice3"

Where enabled will be set to either True or False depending on values of "p" and "m" and the values they are compared against.

For values of p=4 and m=2, your first check would break down to (enabled=True and False) - which in turn breaks down to (enabled=False) (because True and False is False). It's the same way if works, just applied in a slightly different way.

There is part of me that really wants to code it as "choice2" (enabled=(p==4 and m==1)):, because of the extra clarity brackets bring when coding mathematical expressions - at least from a "readability" point of view. But they aren't necessary.
Just remember that each mathematical operator (==, <= etc. will result in either True or False and those Trues and Falses can be compounded with and and or type logic to lead to more True and False answers at each step.

Hopefully that all makes sense and I've just overexplained a bit.
 
  • Like
Reactions: 3DeadAngel

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,111
14,798
File "game/script.rpy", line 1128: expected statement.
choice2_text = "?????"
^
osanaiko was a bit quick and forgot that Ren'Py need Python lines to be prefixed by $. His code should read:
Python:
   if p < 2:
        $ choice2_text = "?????"
    else
        $ choice2_text = "Do a breakdancing move to win her heart"
 

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
Ah ha.

The (enabled=xxx) code would usually be a replacement for the if. You can have both, but it wouldn't make sense in my opinion.

if will either show or not show the menu choice (by default anyway - you already know about config.menu_include_disabled = True)

The changes to the screen choices: screen to check for kwargs, etc. is what makes the enabled control whether the option is sensitive or insensitive to user interactions.

Assuming all the changes from the other thread, I think what you are wanting is more like :

Python:
    menu:
        "choice":
            "I picked choice1"

        "choice2" (enabled=p==4 and m==1):
            "I picked choice2"

        "choice3" (enabled=p<=3 and m<=0):
            "I picked choice3"

Where enabled will be set to either True or False depending on values of "p" and "m" and the values they are compared against.

For values of p=4 and m=2, your first check would break down to (enabled=True and False) - which in turn breaks down to (enabled=False) (because True and False is False). It's the same way if works, just applied in a slightly different way.

There is part of me that really wants to code it as "choice2" (enabled=(p==4 and m==1)):, because of the extra clarity brackets bring when coding mathematical expressions - at least from a "readability" point of view. But they aren't necessary.
Just remember that each mathematical operator (==, <= etc. will result in either True or False and those Trues and Falses can be compounded with and and or type logic to lead to more True and False answers at each step.

Hopefully that all makes sense and I've just overexplained a bit.
Ahh very good explanation even my squid brain was able to get it:D
I think I wasn't clear tho in my previous texts. I have 2 choices only where If the player doesn't meet the points (p=4 and m=1) only a "?????" text should appear instead of the actual choice.
Python:
menu:
    "choice1" #this one always seeable
        "choice1 picked"
    "choice2" (enabled=p==4 and m==1): #this one should be only showing if requirements are true. otherwise completely hidden
        "choice2 picked"
    "?????" (enabled=p==4 and m==1): #this one should be showing if the player doesn't meet the requirement instead of choice2 text, also unclickable which is true
        pass #only here to not get error
 

3DeadAngel

Newbie
Game Developer
May 10, 2023
26
32
osanaiko was a bit quick and forgot that Ren'Py need Python lines to be prefixed by $. His code should read:
Python:
   if p < 2:
        $ choice2_text = "?????"
    else
        $ choice2_text = "Do a breakdancing move to win her heart"
I can't beleive it's you again to the rescue:D Indeed that dollar sign saved my life and I got exactly what I wanted. Thanks a lot to you again:)