"Greyed-out" menu choice

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
rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

"Greyed-out" menu choice

#1 Post by rebellare »

I've been looking around a little and the solutions I found were from a few years back and it seems like the basic naming and writing of code in screens.rpy has changed.
The solution I found was replacing:

Code: Select all

for caption, action, chosen in items:

                if action:

                    button:
                        action action
                        style "menu_choice_button"

                        text caption style "menu_choice"

                else:
                    text caption style "menu_caption"
with:

Code: Select all

for caption, action, chosen in items:

                if action:
                    
                    if " (disabled)" in caption:
                        $ caption = caption.replace(" (disabled)", "") #This replaces the (disabled) in your menu so it doesn't come up
                        button:
                            action None # This means that even if you click the disabled button nothing will happen
                            style "menu_choice_button"
                            
                            text caption style "menu_choice"

                    else:
                        button:
                            action action
                            style "menu_choice_button"

                            text caption style "menu_choice"

                else:
                    text caption style "menu_caption"
But, the current version of Ren'Py (7.1.3.1092) has that screen set up like this:

Code: Select all

    vbox:
        for i in items:
            textbutton i.caption action i.action
So, when I tried doing it, I simply tried like this:

Code: Select all

    vbox:
        for i in items:
            textbutton i.caption action i.action
            for caption, action, chosen in items:
                if action:
                    if "(disabled)" in caption:
                        $ caption = caption.replace(" (disabled", "")
                        button:
                            action None
                            style "choice_button"
                            text caption style "menu_choice"
                    else:
                        button:
                            action action
                            style "choice_button"
                            text caption style "menu_choice"
                else:
                    text caption style "menu_caption"
And, as I presumed, it didn't work. Anyone know an updated version of the same thing? Still a rookie at this so not sure if just renaming a few things might be the actual solution.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: "Greyed-out" menu choice

#2 Post by Remix »

Code: Select all

    vbox:
        for i in items:
            textbutton i.caption.replace(" (disabled", ""):
                action If( "(disabled)" in i.caption, 
                                NullAction(),
                                i.action )
                # style "choice_button"
Should be all you need, though also note you could do something like this for recent Ren'Py releases:

Code: Select all

# show "if condition:" hidden choices as disabled
define config.menu_include_disabled = True

default choice_shown = False # just a variable

label start:

    menu:

        "Choice A" if choice_shown:
            "A"

        "Choice B":
            "B"
Frameworks & Scriptlets:

KingsCard
Newbie
Posts: 14
Joined: Sat Feb 17, 2018 8:58 am
Contact:

Re: "Greyed-out" menu choice

#3 Post by KingsCard »

Shouldn't it be a new feature of version 7.1.3 ? :
Choice menus can now display as insensitive buttons items selected by the if clause.
Didn't tried it yet though.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: "Greyed-out" menu choice

#4 Post by Remix »

Yup, you are right there.

I tend to work with a recent Nightly build so I often don't always notice if a new feature has made it into the Release channel or how long it's been there, oops.
Frameworks & Scriptlets:

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: "Greyed-out" menu choice

#5 Post by rebellare »

KingsCard wrote: Tue Dec 04, 2018 3:47 am Shouldn't it be a new feature of version 7.1.3 ? :
Choice menus can now display as insensitive buttons items selected by the if clause.
Didn't tried it yet though.
Oh, that's what I get for not reading changelogs...

EDIT:
Being the intelligent being that I am, I can't seem to implement the said "if clause". When I run it, it just doesn't show the choice if the variable required isn't met...

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: "Greyed-out" menu choice

#6 Post by Remix »

What code are you trying and are you updated to Ren'Py 7.1.3 ?
Frameworks & Scriptlets:

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: "Greyed-out" menu choice

#7 Post by rebellare »

Managed to get it all to work. Thanks everyone for helping.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot]