Choice buttons, function to change warning on/off [SOLVED]

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
Crystaline Spade
Regular
Posts: 105
Joined: Tue Feb 11, 2014 11:55 pm
Projects: Where the Wind Travels
Tumblr: crystaline-spade
Deviantart: CrystalineSpade
Location: Nottingham(not England though)
Contact:

Choice buttons, function to change warning on/off [SOLVED]

#1 Post by Crystaline Spade »

I hope that title makes sense...
I apologize in advance if there's another topic about this sort of thing. I've just spent an hour searching for one but with no luck. If there is already a topic please send the link. Once again if there is already a topic on this I'm sorry and please tell me so.

Right! So, on to the actual question.

Background Info: I'm making a game right now and for the most part it has a light and happy feel but, can suddenly take a dark turn. Not in terms of you suddenly get a bad ending but that the themes will become darker. At the same time it's possible to play the game and never hit any of the darker themes. Even if I warn people about this I am concerned that they might be unhappy because the choices themselves don't always reflect what will happen. So, I thought it might be a good idea to warn others the choices add darker themes but, I know that some would also be upset if this function was automatic. So, why not add an extra feature to the game that will allow you to choose if you want the warnings or not?

Actual Question: So, simply put is it possible to add a function to the preferences and/or somewhere else that will allow players to choose whether or not they receive warnings of the choices? If so, how would you go about it. I was thinking of just having different colored choice buttons. But I'm still uncertain about how to code that in a way that you can chose if you want the option on or off...

Thank you for taking the time to read my question!

From Spade
Last edited by Crystaline Spade on Mon Jul 06, 2015 10:06 am, edited 2 times in total.
Image an otome game.
Our-Sight(working title)

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Choice buttons, add function that can change warning on/

#2 Post by Onishion »

Ok, I'm hoping someone has a more elegant solution for this, because I've been thinking about similar things myself, but here's a brute force method of doing it:

Code: Select all

default Warning = 0

menu:
    "Do you want dark path warnings?"
    "Yes.":
        $ Warning = 1
    "No.":
        pass
    
menu:
    "Which path do you take?"
    "The right path. [[dark path]" if Warning:          #This displays this version of the line, which will read "The right path. [dark path]", only if they chose "yes."
        jump sad_path
    "The right path." if not Warning:                   #if they chose "no," then this version will display, without a warning. 
        jump sad_path
    "The left path.":
        jump happy_path

User avatar
kitsalai
Regular
Posts: 65
Joined: Wed Jan 08, 2014 11:05 pm
Projects: Imaginatum
Location: US
Contact:

Re: Choice buttons, add function that can change warning on/

#3 Post by kitsalai »

In my personal opinion as a player, I think a having multiple menu choices would be a good way to implement warning messages about certain paths. Changing the colors is a neat idea though.

Onishion's method certainly works but I would make Warning into a persistent variable. I'm not sure how knowledgeable you are with the code in screens.rpy but you'll need SetField("persistent", "Warning", True) action if you want this be in your preference screen. You can look more into it in the documentation.

To change the color, you can edit the choice screen. I forgot where I found this on the forums so I'll just repeat it here.

Code: Select all

screen choice(items):
    window:
        # ...
        vbox:
            # ...
            for caption, action, chosen in items:

                if action:

                    if " (dark)" in caption and persistent.Warning:
                        $ caption = caption.replace(" (dark)", "")
                        button:
                            action action
                            style "menu_choice_button"
                            background "#333333"
                            text caption style "menu_choice"

                    # ...
What this portion will do is change the background color if it finds the string " (dark)" in the menu choice, then remove the " (dark)" portion of the string when displaying it to the user.

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Choice buttons, add function that can change warning on/

#4 Post by Onishion »

Oooh, I might use some of that. Is it possible to tweak that to make it so that a "dark" menu choice is not only gray, but also non-interactive? I've been using the "if something:" part of menus to remove options I don't want to be available to the player, but in at least some cases I would prefer that the option be visible to them, but just not work, so that they'd know that there are conditions in which it would be available, and so that the overall layout of the menu does not fluctuate based on current circumstances.

User avatar
kitsalai
Regular
Posts: 65
Joined: Wed Jan 08, 2014 11:05 pm
Projects: Imaginatum
Location: US
Contact:

Re: Choice buttons, add function that can change warning on/

#5 Post by kitsalai »

Onishion wrote:Oooh, I might use some of that. Is it possible to tweak that to make it so that a "dark" menu choice is not only gray, but also non-interactive? I've been using the "if something:" part of menus to remove options I don't want to be available to the player, but in at least some cases I would prefer that the option be visible to them, but just not work, so that they'd know that there are conditions in which it would be available, and so that the overall layout of the menu does not fluctuate based on current circumstances.
Actually, that's how I was using the bit originally. As I said I found this before, but I can't seem to find it again. Anyway here's what I have as a reference. Biggest difference is "action None" instead of "action action"

screens.rpy:

Code: Select all

screen choice(items):

    window:
        style "menu_window"
        xalign 0.5
        yalign 0.5

        vbox:
            style "menu"
            spacing 2

            for caption, action, chosen in items:

                if action:
                
                    if " (locked)" in caption:
                        $ caption = caption.replace(" (locked)", "")
                        button:
                            action None
                            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"
script.rpy:

Code: Select all

 menu:
        "Easy":
            "..."
        "Normal":
            "..."
        "Hard (locked)" if not persistent.hard:
            pass
        "Hard" if persistent.hard:
            "..."

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Choice buttons, add function that can change warning on/

#6 Post by Onishion »

Thanks, that works great. I combined it with the color changing portion from the previous post to make them both gray and inactive. One thing though, my default menu options have slightly rounded corners, an opaque border, and translucent background, but the "inactive" option just becomes fully opaque with sharp corners. Is there any trick to getting the inactive ones to retain the same styles as the default?

User avatar
kitsalai
Regular
Posts: 65
Joined: Wed Jan 08, 2014 11:05 pm
Projects: Imaginatum
Location: US
Contact:

Re: Choice buttons, add function that can change warning on/

#7 Post by kitsalai »

All of my styles are customized so I'm uncertain which one applies the rounded corners. But to guide you in the right direction, you'll need to change the insensitive_background and other insensitive_ properties.

User avatar
Crystaline Spade
Regular
Posts: 105
Joined: Tue Feb 11, 2014 11:55 pm
Projects: Where the Wind Travels
Tumblr: crystaline-spade
Deviantart: CrystalineSpade
Location: Nottingham(not England though)
Contact:

Re: Choice buttons, add function that can change warning on/

#8 Post by Crystaline Spade »

Okay, yeah, I think I get what you're saying.
Thanks for the help Onishion and kitsalai!

From Spade
Image an otome game.
Our-Sight(working title)

Post Reply

Who is online

Users browsing this forum: No registered users