Make a certain character’s speech text always right align?

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
skinnyfitgenes
Newbie
Posts: 12
Joined: Wed May 12, 2021 11:15 am
Contact:

Make a certain character’s speech text always right align?

#1 Post by skinnyfitgenes »

Hi folks,

I’d like a certain character’s text and name (Josh) to always appear right-aligned, and his name in blue. I thought I had it, but my code isn’t working.

The colour for his name works, but his name is still aligned to the left. If his speech goes onto a second line, then it aligns to the right, but if it’s only a few words and doesn’t go onto a second line, it stays on the left.

Does anyone have any ideas?

define j = character(“Josh”, color=“000080”, what_text_align=1.0)

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Make a certain character’s speech text always right align?

#2 Post by strayerror »

Stab in the dark, but I would guess that the text container (rather than the text within that area) is still left aligned, and so only when the first line stretches that container to be the full width does the alignment of the text within it take effect - manifesting as only affecting the second line onward. Here are two potential solutions (I've not had chance to test either however):

Attempt to align the text container as well as the text inside it:

Code: Select all

define j = character(“Josh”, color=“000080”, what_align=1.0, what_text_align=1.0)
Try to force the text container to always be maximum width:

Code: Select all

define j = character(“Josh”, color=“000080”, what_text_align=1.0, what_xfill=True)
Of the two I'd suggest that (if it works) the first is a better option, as depending on the context xfill can sometimes get a bit over zealous and disrupt surrounding containers.

Good luck!

Post Reply

Who is online

Users browsing this forum: Google [Bot]