[Solved] Inconsistent centering, but only for the first line?

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
User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

[Solved] Inconsistent centering, but only for the first line?

#1 Post by yon »

I've noticed that when I try to display strings as centered, one of them consistently does not display in the center, but rather, off to the side. Or maybe, it's that all of the others are slightly to the side?

Code: Select all

scene black with fade

    # VARIABLE SETTING - change or comment out
    $ v_date = "???"
    $ v_time = "???"
    $ v_area = "???"
    $ v_room = "???"

    # LABELS - do not change
    centered "[v_date]\n
    [v_time]\n\n
    {p=0.25}
    [v_area]\n
    [v_room]"
That gives the result of what is in the first screenshot.
centered 1.PNG
centered 1.PNG (3.68 KiB) Viewed 433 times
I'm not sure why this is happening? When I try to swap the variables for actual text, the first line is still inconsistent with the others:

Code: Select all

# LABELS - do not change
    centered "aaa\n
    bbb\n\n
    {p=0.25}
    ccc\n
    ddd"
How can I make all of the lines display consistently?
Attachments
centered 2.PNG
centered 2.PNG (3.13 KiB) Viewed 433 times
Last edited by yon on Mon Aug 22, 2022 5:28 pm, edited 2 times in total.

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Inconsistent centering, but only for the first line?

#2 Post by yon »

Update-

It all displays correctly if I do this:

Code: Select all

centered "[v_date]\n[v_time]{p=0.25}\n\n[v_area]\n[v_room]"
But why is that?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Inconsistent centering, but only for the first line?

#3 Post by Ocelot »

Second and following lines start with 4 spaces. First one does not.
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Inconsistent centering, but only for the first line?

#4 Post by Imperf3kt »

Instead of a bunch of line breaks, for formatting like this, I'd suggest triple quoted strings
https://www.renpy.org/doc/html/dialogue ... logue-mode
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Inconsistent centering, but only for the first line?

#5 Post by m_from_space »

I suggest using a screen to show something like this to the player, not some "centered" character that is weird anyway in my opinion. And why did you indent lines after "scene black with fade"?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Inconsistent centering, but only for the first line?

#6 Post by Imperf3kt »

m_from_space wrote: Mon Aug 22, 2022 2:04 amAnd why did you indent lines after "scene black with fade"?
Thats a quirk of the forum bbcode.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Inconsistent centering, but only for the first line?

#7 Post by yon »

Imperf3kt wrote: Mon Aug 22, 2022 5:38 am
m_from_space wrote: Mon Aug 22, 2022 2:04 amAnd why did you indent lines after "scene black with fade"?
Thats a quirk of the forum bbcode.
Yeah, I didn't realize it was going to do that.

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Inconsistent centering, but only for the first line?

#8 Post by yon »

Ocelot wrote: Sun Aug 21, 2022 5:17 pm Second and following lines start with 4 spaces. First one does not.
Oh, didn't realize it counted that -- from the indenting, I assume? That makes sense, though.

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Inconsistent centering, but only for the first line?

#9 Post by yon »

m_from_space wrote: Mon Aug 22, 2022 2:04 am I suggest using a screen to show something like this to the player, not some "centered" character that is weird anyway in my opinion. And why did you indent lines after "scene black with fade"?
Would I not still have to find some way to center the text in that case? I'm not sure why using it is bad form in this instance?

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Inconsistent centering, but only for the first line?

#10 Post by yon »

Imperf3kt wrote: Sun Aug 21, 2022 7:03 pm Instead of a bunch of line breaks, for formatting like this, I'd suggest triple quoted strings
https://www.renpy.org/doc/html/dialogue ... logue-mode
I tried doing that, but it keeps giving me issues with indentation, even though it lines up with the rest of the indentation in the label. I tried it at varying distances and all of them gave me errors.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Inconsistent centering, but only for the first line?

#11 Post by m_from_space »

yon wrote: Mon Aug 22, 2022 5:23 pmWould I not still have to find some way to center the text in that case? I'm not sure why using it is bad form in this instance?
Whenever you are intending to show something to the player multiple times in the same format and it's not dialogue, screens are the way to go. You then can easily call the screen with the given parameters like v_date and v_time and it will show it like you expect.

Post Reply

Who is online

Users browsing this forum: Google [Bot], LuckyT