Change a name's color based on a choice? [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
Jadis
Newbie
Posts: 6
Joined: Sun Dec 13, 2015 5:34 am
Projects: Princesses Ever After
Tumblr: princesses-ever-after
Contact:

Change a name's color based on a choice? [SOLVED]

#1 Post by Jadis »

Hi! I am very new to ren'py. I searched, but I can't find anything about how to do this - I'm sorry if I missed something!

What I want to do is when the player makes a certain choice, have that choice affect what color their chosen name displays in for the rest of the game, but I can't figure out how. I've experimented with some ways that seemed plausible, but all of them broke everything. (I tried to use a variable as a hex code and the variable being declared in the choices, and to re-declare the name alias but with a different color in each choice, and I think something else but I've forgotten what.)

How can I do this? (Is it actually possible to do this?)

What I have/want is

Code: Select all

 init:

        $ povname = ""

        $ pov = DynamicCharacter("povname", color=("#fff"))      
    
    $ povname = renpy.input(_("What is your name?")) or _("Jessamine")

# skipping a long section of other stuff that's irrelevant to my question

menu:
        
        "The soft, demure green dress.":
            $ green_dress = True
            $ lpoints += 1
            # something that turns povname green
            jump dressed
        "The fitted, low-cut red silk dress.":
            $ red_dress = True
            $ kpoints += 1
            # something that turns povname red
            jump dressed
        "The quiet, unassuming grey dress.":
            $ grey_dress = True
            $ apoints += 1
            # something that turns povname grey
            jump dressed
        "The leather bodice and breeches.":
            $ leather_pants = True
            $ rpoints += 1
            # something that turns povname brown
            jump dressed
        "The pretty, sparkling purple dress.":
            $ purple_dress = True
            $ mpoints += 1
            # something that turns povname purple
            jump dressed
        "The rich blue velvet tunic and hose.":
            $ blue_velvet = True
            # something that turns povname blue
            jump dressed    
Thank you!
Last edited by Jadis on Sun Dec 13, 2015 1:58 pm, edited 1 time in total.

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Change a name's color based on a choice?

#2 Post by 78909087 »

I think this can be done. Let me test this.

Alright, I created this in a script and it worked fine. I #'ed out your variables when I was testing, since I didn't know what purpose they served (so check them out yourself)- but this should be copy-pasteable right into your game.

Code: Select all

define megreen = DynamicCharacter("povname", color="#00cc00")
define mered = DynamicCharacter("povname", color="#ff0000")
define megrey = DynamicCharacter("povname", color="#808080")
define mebrown = DynamicCharacter("povname", color="#663300")
define mepurple = DynamicCharacter("povname", color="#660066")
define meblue = DynamicCharacter("povname", color="#000066")
define x = DynamicCharacter("povname", color="#000000")


label start:
    $ povname = renpy.input(_("What is your name?")) or _("Jessamine")
    
    menu:
        "The soft, demure green dress.":
            $ green_dress = True
            $ lpoints += 1
            $ x = megreen
            jump dressed
        "The fitted, low-cut red silk dress.":
            $ red_dress = True
            $ kpoints += 1
            $ x = mered
            jump dressed
        "The quiet, unassuming grey dress.":
            $ grey_dress = True
            $ apoints += 1
            $ x = megrey
            jump dressed
        "The leather bodice and breeches.":
            $ leather_pants = True
            $ rpoints += 1
            $ x = mebrown
            jump dressed
        "The pretty, sparkling purple dress.":
            $ purple_dress = True
            $ mpoints += 1
            $ x = mepurple
            jump dressed
        "The rich blue velvet tunic and hose.":
            $ blue_velvet = True
            $ x = meblue
            jump dressed   
    
label dressed:
    x "Okay, so, did it work?"
This was more mind-boggling than difficult. All the variables and options can overwhelm you.
Let me know how it goes. Good luck with further coding.
I am not friends with the sun.
Image

User avatar
Jadis
Newbie
Posts: 6
Joined: Sun Dec 13, 2015 5:34 am
Projects: Princesses Ever After
Tumblr: princesses-ever-after
Contact:

Re: Change a name's color based on a choice?

#3 Post by Jadis »

Hah, sorry, I should have taken out all my variables irrelevant to the question. (So many variables! So many things I'm doing with them!)

However! It works! :D Thank you so much! I was sure there must be some way to do it, I just couldn't work out what.

Post Reply

Who is online

Users browsing this forum: No registered users