Every character in my vn is associated with a color. Hera is bronze, Agamemnon is red, Achilles is dark blue, etc.
What I would like to do is, everytime I insert the name of a character in dialogue, it appears in that color, so it stands out.
Is there a way to do this automatically, or do I have to insert the color code manually each time someone is mentioned?
Can I assign a color to a name/word?
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.
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.
- IchihashiMaiden
- Newbie
- Posts: 15
- Joined: Fri Dec 08, 2017 2:00 am
- Projects: Be A Good Boy (Otome) ; Iliad (VN)
- itch: IchihashiMaiden
- Contact:
Can I assign a color to a name/word?
I have no idea what I'm doing.
(Character in icon belongs to nomnomnami on itch.io)
(Character in icon belongs to nomnomnami on itch.io)
Re: Can I assign a color to a name/word?
You could define the character and give it the color code like so:
Code: Select all
$ a = Character(_("Agamemnon:"),
color="ff0000")
a "Cool my name is in red!"
- IchihashiMaiden
- Newbie
- Posts: 15
- Joined: Fri Dec 08, 2017 2:00 am
- Projects: Be A Good Boy (Otome) ; Iliad (VN)
- itch: IchihashiMaiden
- Contact:
Re: Can I assign a color to a name/word?
Code: Select all
define C1 = Character("Chryses", color="3d352f")
define GS = Character("Greek Soldiers", color="915122")
define A1 = Character("Agamemnon", color="9F111B")
define A2 = Character("Achilles", color="045991")
define dA1 = Character("Apollo", color="ffe766")
define dZ1 = Character("Zeus", color="e6c200")
define dH1 = Character("Hera", color="948532")
I have no idea what I'm doing.
(Character in icon belongs to nomnomnami on itch.io)
(Character in icon belongs to nomnomnami on itch.io)
Re: Can I assign a color to a name/word?
Ah my bad don't know about that never used such feature in my games but I would like to know also if someone can help.
- Ocelot
- Lemma-Class Veteran
- Posts: 2384
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Can I assign a color to a name/word?
Here is a solution using Custom Text Tags:
It extracts name and color from character object itself. To test, create a new project, replace content of script.rpy with this code and run the game.
(We really need a way to define self-closing tags, I would prefer to use {char=e} here)
Code: Select all
init python:
def char_tag(tag, argument, contents):
char = getattr(renpy.store, contents[0][1])
contents = [
(renpy.TEXT_TAG, "color=" + char.who_args["color"]),
(renpy.TEXT_TEXT, char.name),
(renpy.TEXT_TAG, "/color")
]
return contents
config.custom_text_tags["char"] = char_tag
define e = Character("Eileen", who_color="ff0000")
label start:
scene bg room
show eileen happy
e "You've created a new Ren'Py game."
# Notice that I use character object name, not character name here
e "Starring me, {char}e{/char}"
e "Once you add a story, pictures, and music, you can release it to the world!"
return
(We really need a way to define self-closing tags, I would prefer to use {char=e} here)
< < insert Rick Cook quote here > >
- IchihashiMaiden
- Newbie
- Posts: 15
- Joined: Fri Dec 08, 2017 2:00 am
- Projects: Be A Good Boy (Otome) ; Iliad (VN)
- itch: IchihashiMaiden
- Contact:
Re: Can I assign a color to a name/word?
Oh.. I was hoping I could avoid using "init" entirely in this VN. Quite frankly, I find the "init" to be incredibly intimidating for some reason. I don't understand it at all, and the more reading I try to do on it, the more confused I feel. It's a bit overwhelming. (Maybe this is because I never took a proper class on coding, and have been learning by trial and error.)
I guess, then, my only option is to either drop the idea, or do it manually.
Thank you though. I appreciate the effort and suggestion.
I guess, then, my only option is to either drop the idea, or do it manually.
Thank you though. I appreciate the effort and suggestion.
I have no idea what I'm doing.
(Character in icon belongs to nomnomnami on itch.io)
(Character in icon belongs to nomnomnami on itch.io)
Who is online
Users browsing this forum: No registered users