[SOLVED]Locked choices

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
User avatar
waterflame
Newbie
Posts: 4
Joined: Sat Dec 17, 2016 4:41 pm
Contact:

[SOLVED]Locked choices

#1 Post by waterflame »

Code: Select all

    menu testMenu:
        "Option A":
            "You picked Choice A."
        "Option B":
            "You picked Choice B."
        "Option C" if persistent.CanChoice:
            "You picked Choice C."
So I know you can do something like this(see above) and make it so a choice doesn't show up. But how would you make it just display locked? I tried the simplest idea I could think of. Just adding an else(1). Alas this doesn't really work. It errors out... so I tried it with a python if(2) but that also fails. Is there anyway I can do this with out having to say... listing in Screens.py all the choices(3) and check if their condition is triggered each time(I hope so... sounds quite laggy)? I assume there is a better way I'm overlooking.

Code: Select all

(1)
Script.rpy:
    menu testMenu:
        "Option A":
            "You picked Choice A."
        "Option B":
            "You picked Choice B."
        "Option C" if persistent.CanChoice else "Locked":
            "You picked Choice C."
    return

Screens.rpy Choice Screen:
...
if i.caption == "Locked":
 textbutton i.caption
else:
 textbutton i.caption action i.action
...

(2)
    menu confirm:
        "Option A":
            "You picked Choice A."
        "Option B":
            "You picked Choice B."
        $ if persistent.CanChoice:
            "Option C":
              "You picked Choice C."
        $ else:
            "Locked"

(3)
Screens.rpy Choice Screen:
...
            if i.caption == "Option C":
                if persistent.CanChoice:
                    textbutton i.caption action i.action
                else:
                    textbutton "Locked"
            else:
                textbutton i.caption action i.action
...
Last edited by waterflame on Sun Dec 18, 2016 9:40 am, edited 1 time in total.

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

Re: Locked choices

#2 Post by Ocelot »

Something like that:

1) Change choice screen in screens.rpy:

Code: Select all

screen choice(items):
    style_prefix "choice"
    vbox:
        for i in items:
            if i.caption[0] == '!':
                textbutton i.caption[1:] action None
            else:
                textbutton i.caption action i.action
2) Now any menu item which starts with ! will be represented by inactive button. Make two choices with complementary conditions (only one or other will be shown):

Code: Select all

label start:
    $ locked = True
    menu menu1:
        "Unlock":
            $ locked = False
            jump menu1
        "!Locked" if locked:
            pass
        "Locked" if  not locked:
            'You get the secret choice'
    return
< < insert Rick Cook quote here > >

User avatar
waterflame
Newbie
Posts: 4
Joined: Sat Dec 17, 2016 4:41 pm
Contact:

Re: Locked choices

#3 Post by waterflame »

Ocelot wrote: -snip-
Thank you! Mind if I ask how I'd go about changing the choice button image? Is it as simple as some how assigning it a property like gui.button.choice_background = "new path" ?

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

Re: Locked choices

#4 Post by Ocelot »

You can change gui/button/choice_hover_background.png and gui/button/choice_idle_background.png

You might want to read on styles and style properties to make buttons look like you want
< < insert Rick Cook quote here > >

User avatar
waterflame
Newbie
Posts: 4
Joined: Sat Dec 17, 2016 4:41 pm
Contact:

Re: Locked choices

#5 Post by waterflame »

Thanks again @Ocelot! Nothing fancy for now... But it works!
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot], Lucyper, Majestic-12 [Bot]