A way to color certain 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
Jaitzche
Newbie
Posts: 13
Joined: Sun Jan 07, 2018 1:26 am
Contact:

A way to color certain choices?

#1 Post by Jaitzche »

I know there is a way to change the color of a choice, but I'm trying to find a way where a specific choice is a certain color, rather than all choices are the same color.

I looked at documentation for it, where it said to use {color #whatever}Red{/color} but if I try that it doesn't work and just jumps to the next label (it's a customization thing so it's supposed to jump to the previous label). Is it something I just can't do with choices?

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: A way to color certain choices?

#2 Post by rames44 »

If you typed it in your program exactly as you have it in your question, you’re missing an equal sign between “color” and the #

This should work. Do you want to post the code for a menu where it isn’t working?

Jaitzche
Newbie
Posts: 13
Joined: Sun Jan 07, 2018 1:26 am
Contact:

Re: A way to color certain choices?

#3 Post by Jaitzche »

rames44 wrote: Tue Mar 19, 2019 12:25 pm If you typed it in your program exactly as you have it in your question, you’re missing an equal sign between “color” and the #

This should work. Do you want to post the code for a menu where it isn’t working?
Okay, so I realized I stated the wrong issue. Turns out it does work but I guess not where I want it to? The actual choice, it does the color, but cycling through the colors is what gives it an issue-

Code: Select all

label start1_2
"Eye Color: [eyes]":
        if eyes == "Red": #This is the text I wanted to change with the colors.
            $ eyes = "Purple"
            jump start1_2
        if eyes == "Purple" #And then this would be purple.
            $ eyes = "Some other color"
            jump start 1_2
           etc.
"next":
	jump some_other
label some_other  
Basically, what I have it do is you click on the choice, it changes the text/color and then loops back to the previous label, so it doesn't look like the page has changed at all save for the choice. Except if I try to change "Red" to a color (the one I specified above), it jumps to the next label (some_other) rather than looping back.

Ultimately, it's no big deal. Just thought it would be neat if I could.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: A way to color certain choices?

#4 Post by rames44 »

So, just to make sure I understand what it is that you’re trying to do - when someone chooses “Red,” what you want is for the text of the menu to change to the corresponding color? Instead of (or in addition to) interpolating the name of the color via “[eyes]”?

(Just want to make sure I understand the nature of the problem so I’m not working on the wrong thing)

Jaitzche
Newbie
Posts: 13
Joined: Sun Jan 07, 2018 1:26 am
Contact:

Re: A way to color certain choices?

#5 Post by Jaitzche »

rames44 wrote: Wed Mar 20, 2019 11:28 am So, just to make sure I understand what it is that you’re trying to do - when someone chooses “Red,” what you want is for the text of the menu to change to the corresponding color? Instead of (or in addition to) interpolating the name of the color via “[eyes]”?

(Just want to make sure I understand the nature of the problem so I’m not working on the wrong thing)
Yes. If it's something convoluted or more difficult than I realize, don't worry about it. Just thought it'd be a nice effect.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: A way to color certain choices?

#6 Post by rames44 »

No, it's not that bad - I just wanted to make sure that I was heading in the direction that you wanted.

The thing you have to deal with is that colors aren't specified by names - they're specified by codes. So you need to do something like what I've shown before. Essentially, I create two variables - one with the human-readable color name, and the second with the hex color code, and substitute them both into the menu choice. Variable substitution is performed before the text tags are evaluated, so I can essentially stuff in the color code dynamically. (At least, with Ren'py 7.1.3, which is what I'm currently using.)

Code: Select all

default color_name = 'Red'
default color_code = '#f00'

label start:

label ask_the_question:
    menu:
        "Change color - currently {color=[color_code]}[color_name]{/color}":
            menu:
                "Change to {color=#f00}Red{/color}" if color_name != 'Red':
                    $ color_name = 'Red'
                    $ color_code = '#f00'
                    jump ask_the_question

                "Change to {color=#0f0}Green{/color}" if color_name != 'Green':
                    $ color_name = 'Green'
                    $ color_code = '#0f0'
                    jump ask_the_question

                "Change to {color=#00f}Blue{/color}" if color_name != 'Blue':
                    $ color_name = 'Blue'
                    $ color_code = '#00f'
                    jump ask_the_question
        "Done":
            pass

    "All set"
    return

Jaitzche
Newbie
Posts: 13
Joined: Sun Jan 07, 2018 1:26 am
Contact:

Re: A way to color certain choices?

#7 Post by Jaitzche »

rames44 wrote: Wed Mar 20, 2019 3:27 pm No, it's not that bad - I just wanted to make sure that I was heading in the direction that you wanted.

The thing you have to deal with is that colors aren't specified by names - they're specified by codes. So you need to do something like what I've shown before. Essentially, I create two variables - one with the human-readable color name, and the second with the hex color code, and substitute them both into the menu choice. Variable substitution is performed before the text tags are evaluated, so I can essentially stuff in the color code dynamically. (At least, with Ren'py 7.1.3, which is what I'm currently using.)

Code: Select all

default color_name = 'Red'
default color_code = '#f00'

label start:

label ask_the_question:
    menu:
        "Change color - currently {color=[color_code]}[color_name]{/color}":
            menu:
                "Change to {color=#f00}Red{/color}" if color_name != 'Red':
                    $ color_name = 'Red'
                    $ color_code = '#f00'
                    jump ask_the_question

                "Change to {color=#0f0}Green{/color}" if color_name != 'Green':
                    $ color_name = 'Green'
                    $ color_code = '#0f0'
                    jump ask_the_question

                "Change to {color=#00f}Blue{/color}" if color_name != 'Blue':
                    $ color_name = 'Blue'
                    $ color_code = '#00f'
                    jump ask_the_question
        "Done":
            pass

    "All set"
    return
It works perfectly! Thanks so much!

Post Reply

Who is online

Users browsing this forum: apocolocyntose