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.
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#1
Post
by niho » Thu May 26, 2022 6:16 pm
Hello, I searched the forum for a bit but I couldn't find exactly what I'm looking for. I'm trying to style my dialogue so that the speaker name is displayed in front of spoken text like movie subtitles. Here's an example of what I mean:

I know I could just manually add the name as part of the dialogue, but I wanted to see if there's a way to do it using the default namebox (so I can use my predefined character names and colors). I assume I'd have to reposition the namebox in the gui but I'm not sure how to account for varying lengths of dialogue text. Any ideas?
Last edited by
niho on Sun May 29, 2022 1:44 pm, edited 1 time in total.
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#2
Post
by Ocelot » Fri May 27, 2022 5:33 am
How exactly do you want to position your namebox and text?
* Name always starts at the same position, text immediately after (position of text would shift depending on name length)? hbox with automatically sized Text displayables is the answer.
* Text always starts at certain position, name immediately precedes it? hbox with fixed size name, which is aligned to the right or two separate Text displayabkes, name with xanchor 1., text with xanchor 0., both positioned at same x-coordinate.
* Something else?
< < insert Rick Cook quote here > >
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#3
Post
by niho » Fri May 27, 2022 6:30 pm
* Name always starts at the same position, text immediately after (position of text would shift depending on name length)? hbox with automatically sized Text displayables is the answer.
Sorry, I'm not sure what you mean by "automatically sized Text displayables." As in simply putting the text in an hbox and using the default style properties? I tried that but the namebox would always appear above the dialogue (even when I gave them the same x-coordinates).
I also tried using yalign to position them. It works somewhat but since they're treated as two different displayables it doesn't have the same effect for multiline dialogue. Here's my current code and the (unintended) effect:
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
hbox:
id "namebox"
style "namebox"
if who is not None:
text who id "who"
text what id "what" yalign 0.8

-
zmook
- Veteran
- Posts: 421
- Joined: Wed Aug 26, 2020 6:44 pm
-
Contact:
#4
Post
by zmook » Fri May 27, 2022 10:34 pm
You have different font sizes in this example, unlike your first "Mickey: Whoever you are…" example. So I'm not sure wha you think should be correct behavior here.
But you can get consistent vertical positioning if you set "yalign 0" on both the 'who' box and the 'what' box. If you want to match the text baselines across both, even when you're using different font sizes, then that's a fixed number of pixels offset. I think you can get that with something more like:
Code: Select all
hbox:
id "namebox"
style "namebox"
if who is not None:
text who:
id "who"
yanchor renpy.BASELINE
ypos 24 # your larger font size, probably
text what:
id "what"
yanchor renpy.BASELINE
ypos 24 # your larger font size, probably
No idea if 24 will be the right px offset for you, but you can fiddle until it looks right. Both text fields would want the same integer value, whatever it is.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#5
Post
by niho » Sun May 29, 2022 3:47 am
No matter how much I fiddled with the offset/pos/whatever values I just couldn't get it to look the way I wanted, even when the fonts were the same size. I finally found a workaround but I've realized that this is probably more trouble than it's worth... (because I'd have to redefine the characters' names as text tags anyways). If anyone has any other ideas I'm open to suggestions but I'll probably just mark this as solved

Thank you both for your help.
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#6
Post
by m_from_space » Sun May 29, 2022 5:15 am
The say screen has to include a text-object with id "what" containing the same text as the argument "what". The "who" id doesn't seem to matter on the other hand. So my workaround for your initial question would be: Hide the "what" text outside of the screen and create your subtitle line. (You may want to think about what happens when you present the user with a choice screen though.)
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
# the original what object, just shifted to the right, out of the screen
text what id "what" xpos 1.0 slow_cps False
# your subtitle like dialogue
if who is None:
text "[what]" slow_cps True
else:
text "[who]: [what]" slow_cps True
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#7
Post
by niho » Sun May 29, 2022 1:44 pm
I did something similar, but it seems like as long as you don't give an id the text won't be styled properly. So either way I'd have to use custom text tags, but thank you.
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#8
Post
by m_from_space » Sun May 29, 2022 2:37 pm
What do you mean by it not being styled properly? You can add styles. I thought your goals is to have a similar styling than in your original post. Also if you want to add a character's style as part of the "what" argument, you can just define the character like this:
Code: Select all
define niho = Character("Niho", what_prefix="{=nihospeak}", what_suffix="{/nihospeak}")
style nihospeak:
font: ...
size: ...
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#9
Post
by niho » Sun May 29, 2022 3:25 pm
Sorry, I should've been more clear. I know how to style the text myself, I meant that it won't be styled automatically using the gui config variables without the who/what id. Also I got the look I wanted, I was just looking for an easier way to do it lol. Though I didn't think of using prefix/suffix so I'll play around with it some more. Thanks again

-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#10
Post
by m_from_space » Wed Jun 01, 2022 1:08 am
niho wrote: ↑Sun May 29, 2022 3:25 pm
Sorry, I should've been more clear. I know how to style the text myself, I meant that it won't be styled automatically using the gui config variables without the who/what id. Also I got the look I wanted, I was just looking for an easier way to do it lol. Though I didn't think of using prefix/suffix so I'll play around with it some more. Thanks again
I literally just woke up and the solution hit right in my face, I actually gave it to myself inside the last post without realizing. It's so much easier and I am really laughing about how I wanted to solve this in such a complex way.
Just create your character like the following.
This way nothing about styles changes, it's everything you need with a single argument inside. (Still wondering why I didn't think about it first.)
Code: Select all
define m = Character(None, ... , what_prefix="Mickey: ")
-
zmook
- Veteran
- Posts: 421
- Joined: Wed Aug 26, 2020 6:44 pm
-
Contact:
#11
Post
by zmook » Wed Jun 01, 2022 9:30 am
m_from_space wrote: ↑Wed Jun 01, 2022 1:08 am
This way nothing about styles changes, it's everything you need with a single argument inside.
Clever! But that won't lay out the hanging indent for the second line, if the dialog is long.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#12
Post
by m_from_space » Wed Jun 01, 2022 3:42 pm
zmook wrote: ↑Wed Jun 01, 2022 9:30 am
Clever! But that won't lay out the hanging indent for the second line, if the dialog is long.
I don't understand, what do you mean?
-
niho
- Newbie
- Posts: 17
- Joined: Fri Apr 15, 2022 11:31 pm
- itch: nihomi
- Discord: niho#0953
-
Contact:
#13
Post
by niho » Wed Jun 01, 2022 7:37 pm
m_from_space wrote: ↑Wed Jun 01, 2022 1:08 am
Code: Select all
define m = Character(None, ... , what_prefix="Mickey: ")
This also works but afaik there's no way to change the color of the prefix alone so I'd still need to use text tags. I have found other uses for prefixes/suffixes though so I appreciate the suggestion.
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#14
Post
by m_from_space » Thu Jun 02, 2022 4:23 am
niho wrote: ↑Wed Jun 01, 2022 7:37 pm
This also works but afaik there's no way to change the color of the prefix alone so I'd still need to use text tags. I have found other uses for prefixes/suffixes though so I appreciate the suggestion.
This solves exactly what you where asking for in your original question, so I don't quite understand the reaction. What exactly do you mean by "not be able to change the color of the prefix alone"? Of course you can change the color of the prefix, it's just text. What's the problem with text tags anyway?
-
zmook
- Veteran
- Posts: 421
- Joined: Wed Aug 26, 2020 6:44 pm
-
Contact:
#15
Post
by zmook » Thu Jun 02, 2022 8:30 am
m_from_space wrote: ↑Wed Jun 01, 2022 3:42 pm
zmook wrote: ↑Wed Jun 01, 2022 9:30 am
Clever! But that won't lay out the hanging indent for the second line, if the dialog is long.
I don't understand, what do you mean?
If the line of dialog wraps in the text box, you'll get
Code: Select all
Mickey: Whoever you are on that
train, listen up
instead of
Code: Select all
Mickey: Whoever you are on that
train, listen up
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Users browsing this forum: Bing [Bot]