Disabling/Enabling Menu Items/Options

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.
Message
Author
Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Disabling/Enabling Menu Items/Options

#1 Post by Siri »

Hi,

Me and my partner are attempting to make a game (obviously XD)

However, I am curious. How would one go about disabling options?

For example, let's say I completed Dark One and I return to the main menu. What I see now would be:

Dark 1

Dark 2

Now Dark 2 is available. How do I make it that while Dark 1 appears as an option, I cannot access it anymore (essentially disable it/grey out)? Please show examples of the code and make the explanation clear (even with details one would dismiss as casual knowledge in programming, as me and my partner are not computer programmers and are essentially newbies at this)?

Thank you :)

(Just a side note, this question was on my other thread, but I am uncertain of how this system works and whether people will see a reply to myself? > . <)

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#2 Post by PetPeeve »

Assuming you are using textbuttons (Although you can do something similar with imagemaps and imagebuttons) this goes in the screens.rpy on the menu you want it on.

Code: Select all

        if not persistent.dark01:
            textbutton _("Dark 1") action Start('dark01')
        if persistent.dark01:
            textbutton _("Dark 2") action Start('dark02')
Then at the end of Dark One make sure you have a persistent.

Code: Select all

    $ persistent.dark01 = True
And of course label the two seperate starts so it goes to the right place.

Code: Select all

label dark01: #THIS IS THE IMPORTANT BIT
    
    "This is dark one."
    return
    
label dark02: #THIS IS THE IMPORTANT BIT
    
    "This is not dark one"
    return
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#3 Post by Siri »

Sorry if I confused you, but I am not using text buttons at all XD I am in the script thing, which means that I have for example:

if persistent.LuluDark_2 == True:

menu:
"Dark 1":
jump DarkLulu1
"Dark 2":
jump DarkLulu2

The thing is I want to be able to disable DarkLulu1 (meaning you cannot access it anymore), as it is already completed. How would one go about doing that (please use examples of codes if you can)? Thanks :)

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#4 Post by PetPeeve »

Oh, that's even easier.

Code: Select all

menu: 
    "Dark 1" if not persistent.LuluDark_1:
        jump DarkLulu1
    "Dark 2":
        jump DarkLulu2
So if the DarkLulu1 event is complete the button will no longer come up this way...

I believe that to make the option stay there, and just be grey, you just need to define the insensitive style somewhere (probably best in the options screen).

Something like this

Code: Select all

    style.menu_choice.insensitive_color = "#808080"
    style.menu_choice_button.insensitive_color = "#ffffff"
Edit: P.S. When you put code on the forum it is best to use the code style so you maintain your spaces
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#5 Post by Siri »

For some reason it isn't working? Could you possibly clarify? Maybe I did something wrong (I just copied what you did into the thing, probably I missed something> . <)?

Here is how the code looks like in script (without the parts you added) (we are just in a testing phase right now and this is not the final product):

Code: Select all

label start:
    
    play music "Diabolik Lovers Anime Music.mp3"
    
    scene Blood Moon Background
    
    menu:
        
        "Lulu Nohikari's Route":
            jump LuluRoute
             
    label LuluRoute:
        
        scene Blood Moon Background
        
        play music "Lulu's Theme Song.mp3"
        
        if persistent.LuluDark_1 == True:
            
            menu: 
                "Main Prologue":
                    jump LuluRoute
                "Dark":
                    jump DarkLulu
                    
        if persistent.LuluDark_2 == True:
            
            menu: 
                "Main Prologue":
                    jump LuluRoute
                "Dark":
                    jump DarkLulu

        else:
            
            menu: 
                "Main Prologue":
                    jump MainProloguelulu
               
            label MainProloguelulu:
                scene Mansion Background           
                play music "Rain and Thunder Sound Effect.mp3"
                $ persistent.LuluDark_1 = False
                $Points = 0
                $ Kside = Character(_('Lulu Nohikari'), color="#FFFFFF", window_left_padding=160, show_side_image=Image("LuluN.jpg", xalign=0.0, yalign=1.0), what_slow_cps=20, ctc= "ctc", ctc_position="fixed")
                    
                Kside "____I hear the rain;"
                    
                Kside "How nice."
                
                menu:
                    "Apple":
                        $ Points += 5
                        $ persistent.LuluDark_1 = True
                        jump LuluRoute
                    "Oranges":
                        $ Points -= 5
                        $ persistent.LuluDark_1 = True                       
                        jump LuluRoute

           
            label DarkLulu:
                
                if persistent.LuluDark_1 == True:
                    
                    menu:
                        "Dark 1":
                            jump Dark1Lulu
                            
                if persistent.LuluDark_2 == True:
                    
                    menu:
                        "Dark 1":
                            jump DarkLulu
                        "Dark 2":
                            jump Dark2Lulu
                            
                    label Dark1Lulu:
                    play music "Amanda - Aisha Duo.mp3"
                    scene Background
                    $ persistent.LuluDark_1 = True
                    $ persistent.LuluDark_2 = False
                    show Kanato Sakamaki
                    k "If you don't give me cake, Teddy will devour your soul!"
                    show Subaru Sakamaki at right
                    S "Tch, you hysteric. Why don't you get your own cake."
                    menu:
                        "Apple":
                            $ Points += 5
                            $ persistent.LuluDark_1 = False
                            $ persistent.LuluDark_2 = True
                            jump LuluRoute
                        "Oranges":
                            $ Points -= 5
                            $ persistent.LuluDark_1 = False
                            $ persistent.LuluDark_2 = True                      
                            jump LuluRoute
 
                    label Dark2Lulu:
                    play music "Amanda - Aisha Duo.mp3"
                    scene Background
                    show Kanato Sakamaki
                    $ persistent.LuluDark_2 = True
                    k "If you don't give me cake, Teddy will devour your soul!"
                    show Subaru Sakamaki at right
                    S "Tch, you hysteric. Get your own cake."
                    
                    menu:
                        "Apple":
                            $ Points += 5
                            $ persistent.LuluDark_2 = False
                            jump Endings
                        "Oranges":
                            $ Points -= 5
                            $ persistent.LuluDark_2 = False                  
                            jump Endings
                    
                    label Endings:
                        
                        if Points >= 10:
                            
                            "Best Ending"
                            
                            return
                            
                        if Points < 10:
                            
                            "Worst Ending"
                            
                            return
Last edited by Siri on Tue May 24, 2016 6:09 am, edited 1 time in total.

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#6 Post by PetPeeve »

Please put the code in between the code tags because I can't see your indents, which makes it difficult to fix.

Edit:

Is this the bit where you want the menu to be enabled/disabled?

Code: Select all

label DarkLulu:

    if persistent.LuluDark_1 == True:

        menu:
            "Dark 1":
                jump Dark1Lulu

    if persistent.LuluDark_2 == True:

        menu:
            "Dark 1":
                jump DarkLulu
            "Dark 2":
                jump Dark2Lulu
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#7 Post by Siri »

Sorry cx I am a bit new here, but yes here would be where I want it to be :) (meaning I would like Dark 1 to now be disabled as it is completed):

Code: Select all


    if persistent.LuluDark_2 == True:

        menu:
            "Dark 1":
                jump DarkLulu
            "Dark 2":
                jump Dark2Lulu
Thank you so much :)

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#8 Post by PetPeeve »

Ok, so to simply remove the option, replace that with:

Code: Select all

label DarkLulu:
    menu:
        "Dark 1" if not persistent.LuluDark_1:
            jump Dark1Lulu
        "Dark 2" if persistent.LuluDark_1:
            jump Dark2Lulu
If you want the option to stay on the screen and be unclickable, it gets a little more complicated.

Instead, use

Code: Select all

label DarkLulu:
    menu:
        "Dark 1" if not persistent.LuluDark_1:
            jump Dark1Lulu
        "Dark 2 (disabled)" if not persistent.LuluDark_1:
            pass
        "Dark 2" if persistent.LuluDark_1:
            jump Dark2Lulu
Then in screens.rpy find the bit of code that says

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"
and replace it 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"
Hopefully I've made it easy enough for you to do it =) Also, it might be a good idea to clear your persistent from the Ren'py dashboard before you test it.
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#9 Post by Siri »

It works :D Thank you so much for your help, I couldn't have done it without you.

Since you have been greatly helpful, perhaps you could help me with another matter?

Is there any way to make it so that the text box looks like the link (including the Speaker part as a permeant part of the text box (the name of the speaker itself changing with the general code))?

http://nicoblog.org/wp-content/uploads/ ... 42ef_o.jpg

Also, could we get the menu screen to look something like this (doesn't have to be exact or anything, but somewhat) (also replace the people with like text boxes/menu options of Main Prologue, Dark, etc. etc. cx):

http://cdn.wikimg.net/strategywiki/imag ... select.png

Furthermore, could we change to box of the menus choices (for example if you are choosing between apples and oranges) to look slightly different (like below at 3: 43):

https://www.youtube.com/watch?v=Efr9x2L_9G8

You can work with the code that we have above (other than the disabled feature implemented, it has remained the same) Sorry if this seems a bit much and thanks a lot in advance :)
Last edited by Siri on Tue May 24, 2016 7:03 am, edited 1 time in total.

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#10 Post by PetPeeve »

Do you just want the name in a separate window?
Because that can easily be done just by adding 'show_two_window = True" when you define your characters.

For example:

Code: Select all

define q = Character('Quinn', show_two_window=True)
To make it look exactly like that, that would take some customizing. Have a look at https://www.renpy.org/wiki/renpy/doc/co ... appearance
And also viewtopic.php?f=8&t=9233
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#11 Post by Siri »

I will be looking at those (as they appear to answer my question), but the only thing they do not appear to address is:

-- the change to box of the menus choices (for example if you are choosing between apples and oranges) to look slightly different (like below at 3: 43):

https://www.youtube.com/watch?v=Efr9x2L_9G8

-- the menu screen to look something like this (doesn't have to be exact or anything, but somewhat) (also replace the people with like text boxes/menu options of Main Prologue, Dark, etc. etc. cx):

http://cdn.wikimg.net/strategywiki/imag ... select.png

How would one go about doing that? Thanks a lot :)

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#12 Post by PetPeeve »

Have a look at this: http://fuckyeahrenpy.tumblr.com/post/97 ... me-choices\

Actually, since you seem super new to Ren'py, I would recommend checking out http://renpyhandbook.tumblr.com/code-tutorials as well, there is lots of useful stuff on there.
Avatar by shiohh
ImageImageImageImage

Siri
Newbie
Posts: 18
Joined: Mon May 23, 2016 4:45 pm
Contact:

Re: Disabling/Enabling Menu Items/Options

#13 Post by Siri »

Thank you so much, you have been really helpful with providing information and resources (you noticed that I was extremely new to renpy, I am (1 week newbie pretty much) XD I guess it was rather obvious cx) :)

User avatar
PetPeeve
Regular
Posts: 70
Joined: Tue Nov 06, 2012 10:40 am
Tumblr: agamemakingblogforcoolkids
Contact:

Re: Disabling/Enabling Menu Items/Options

#14 Post by PetPeeve »

No problem, we were all newbies once =)
Avatar by shiohh
ImageImageImageImage

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Disabling/Enabling Menu Items/Options

#15 Post by namastaii »


Post Reply

Who is online

Users browsing this forum: Kocker