Hello!
So, I want to highlight the name of the characters with her own color each time they are mentioned in a dialogue, each time another character mentions them. In general, each time their name appears on a text box.
So far, I've been doing it by adding, again and again, a {color} tag each time a name appears, but it happens that the characters of my game are very affectionate and they like to call each other by their names.
So is there a way to display a certain word in a certain color each time it appears on a text box without having to use a {color} tag?
[Solved] Avoiding using a {color} tag each time a word is mentioned?
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.
-
- Regular
- Posts: 141
- Joined: Fri Mar 15, 2019 8:46 am
- Completed: Clockwork Poison
- Projects: Melodic Dates, Clockwork Poison: Salvation
- Contact:
[Solved] Avoiding using a {color} tag each time a word is mentioned?
Last edited by Adrian_DVL on Thu Apr 18, 2019 8:49 am, edited 1 time in total.
- Marionette
- Regular
- Posts: 128
- Joined: Thu Apr 21, 2011 12:04 pm
- Completed: https://marionette.itch.io/
- Projects: Get Meowt of Here
- Deviantart: rexx9224
- itch: marionette
- Location: Ireland
- Discord: Marionette#2995
- Contact:
Re: Avoiding using a {color} tag each time a word is mentioned?
You could try setting the name up with the tag as a variable and adding it that way.
Eg
Eg
Code: Select all
#Define it like so
$Mark = "{color=#ffffff}Mark{/color}"
# Use it like so
"Hey its [Mark]."
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Avoiding using a {color} tag each time a word is mentioned?
If you define your characters in the character namespace ( define character.e = Character(...) rather than just define e = Character(...) ) you can add a bit of automation using iteration and say_menu_text_filter:
Code: Select all
default pc = "Bob"
define character.b = Character("[pc]", who_color="00F")
define character.e = Character("Eileen", who_color="F00")
init python:
char_colours = {}
for key in character.__dict__:
char = getattr( character, key )
if hasattr( char, 'who_args' ):
colour = char.who_args.get('color', None)
if colour:
char_colours[ char.name ] = (
"{{color={colour}}}{name}{{/color}}".format(
name=char.name, colour='#{0}'.format(colour)))
def colourize_names( str_to_test ):
for name in char_colours:
str_to_test = str_to_test.replace(name, char_colours[name])
return str_to_test
define config.say_menu_text_filter = colourize_names
label start:
e "My name is Eileen..."
b "Hi Eileen, my name's [pc]"
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
-
- Regular
- Posts: 141
- Joined: Fri Mar 15, 2019 8:46 am
- Completed: Clockwork Poison
- Projects: Melodic Dates, Clockwork Poison: Salvation
- Contact:
Re: Avoiding using a {color} tag each time a word is mentioned?
Tried both ways and both work! I like best Remix's one, since I don't even have to use square brackets, but to mark this thread as solved.
Anyway, thank you so much to both of you!
Anyway, thank you so much to both of you!
Who is online
Users browsing this forum: No registered users