Change narration text color with background
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.
Change narration text color with background
Hiya, I'm trying to make a simple text-based game with Ren'Py. Some scenes take place on Earth and some in space. The scenes in space have a black background, while the ones on Earth have a white background. This being the case, I need to constantly switch between white and black narration text, respectively. It seems that I could use this: https://www.renpy.org/doc/html/gui_adva ... ui-rebuild I'm new to coding though, so I have no clue how this would work for my specific case.
- Draziya
- Regular
- Posts: 70
- Joined: Sun Nov 26, 2017 8:50 am
- Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
- Projects: I'm a love interest in my childhood friend's reverse harem!!
- Organization: Watercress
- itch: Drazillion
- Contact:
Re: Change narration text color with background
You could always define a second narrator for the black text:
Code: Select all
define black = Character (None, what_color="#000")
Re: Change narration text color with background
Yeah. I was just looking for a way to not have to write black before everything.
Re: Change narration text color with background
So, this is the default say() screen in screens.rpy file. Say screen is the screen that contains a textbox, a name, a dialogue... All that fancy stuff:
Now, long story short, it basically takes the name of the character talking ("who") and the dialogue ("what") and displays it in some windows.
Focus on the text what id "what" , that is the line that displays the dialogue. First, let's branch it out onto multiple lines by adding a colon.
Now we need something that will determine the color used. For this, we will use a simple variable.
This simple code will add the "color" tag to our text, changing the color. But remember, variables always need to be defined before they are used. And because we need it defined before the screens are defined, we need to put it into init block.
Just outside of the screen, behind if not renpy.variant..., like this:
This will set the variable to "white" by default. Currently, it will show white text, and if we were to change that variable to anything else with $ colorOfText = "something", the text will turn red (#FF0000). Of course, you can customize this by changing the if/else branch.
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
if who is not None:
window:
style "namebox"
text who id "who"
text what id "what"
## If there's a side image, display it above the text. Do not display on the
## phone variant - there's no room.
if not renpy.variant("small"):
add SideImage() xalign 0.0 yalign 1.0
Focus on the text what id "what" , that is the line that displays the dialogue. First, let's branch it out onto multiple lines by adding a colon.
Code: Select all
text what:
id "what"
Code: Select all
text what:
id "what"
if colorOfText == "white":
color "#FFFFFF"
else:
color "#FF0000"
Just outside of the screen, behind if not renpy.variant..., like this:
Code: Select all
if not renpy.variant("small"):
add SideImage() xalign 0.0 yalign 1.0
init -2 python:
colorOfText = "white"
This will set the variable to "white" by default. Currently, it will show white text, and if we were to change that variable to anything else with $ colorOfText = "something", the text will turn red (#FF0000). Of course, you can customize this by changing the if/else branch.
Re: Change narration text color with background
Thanks much!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]