[Solved] Help changing colors of variables in text

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
ninefoldrin
Newbie
Posts: 9
Joined: Thu Dec 27, 2018 12:40 am
Contact:

[Solved] Help changing colors of variables in text

#1 Post by ninefoldrin »

I'm not entirely sure how to phrase the subject, so let me explain what I'm trying to do.

Every time character names come up in dialogue, I want their names to appear in the same color as their defined character names.

So far I've been doing it like this:

Code: Select all

$   Mia = "{color=FF2626}Mia{/color}"
and then just adding [Mia] wherever her name pops up in dialogue and narration.

I would also like to do this with the player character, but the player character name is user-defined.

Code: Select all

python:
        name = renpy.input("My name is...")

        name = name.strip() or "Tom"
When I use [name] in the definition of the player character, it works like I want, however, when I use [name] in the code similar to the example with Mia, it just displays "[name]" in the PC's color in the game.

Is it possible to do something similar to $ PC = "{color=F6D295}[name]{/color}" and get it to work, or is there a better way to handle all of this?
Last edited by ninefoldrin on Mon Feb 04, 2019 12:40 am, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Help changing colors of variables in text

#2 Post by philat »

$ name = "{color=FF2626}" + name + "{/color}"

ninefoldrin
Newbie
Posts: 9
Joined: Thu Dec 27, 2018 12:40 am
Contact:

Re: Help changing colors of variables in text

#3 Post by ninefoldrin »

Thank you so much!

Post Reply

Who is online

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