add Test center text? [SOLVED]

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
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

add Test center text? [SOLVED]

#1 Post by Westeford »

TL;DR Solution

Code: Select all

add Text ( "Your Text Here", text_align=0.5, slow=True) xcenter 0.5
Thanks Per K Grok
Original Post
I feel like I've been asking too many things lately.
Anyway, so I have a screen and I want to center the text.
Here is my current code for this screen.

Code: Select all

screen testimony:
     fixed: #The important part
        xysize (680, 189) #(735, 122)
        xpos 300 #273
        ypos 481 #573
        add Text ( "{size=50}[sta]", slow=True ) xcenter 0.5
        
    imagemap:
        ground "UI/debate_ui.png"
        #Evidence
        hotspot (7, 563, 286, 75) action Function(cycle_bullet, 1)
        hotspot (7, 639, 286, 75) action Function(cycle_bullet, -1)
        #Advance Testimony
        hotspot (987, 563, 286, 150) action Return()
    fixed:
        xysize (680, 50)
        xpos 300
        ypos 670
        text "{}".format(eval('bullet'+ str(bullet_selected)) ) color "#000" size 50 yalign 0.5
This works perfectly fine, the problem is with the text's alignment. It's centered, but look at this screenshot.
screenshot0005.png
The text as a whole is centered, but the bottom line isn't centered.

So my question, is there a way to make center the lines of text in a screen?
I welcome any input and suggestions. Thank you for your time.
Last edited by Westeford on Thu Mar 28, 2019 2:30 pm, edited 2 times in total.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: add Test center text?

#2 Post by Per K Grok »

Westeford wrote: Thu Mar 28, 2019 12:00 am ------

So my question, is there a way to make center the lines of text in a screen?

-------
text_align 0.5

User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Re: add Test center text?

#3 Post by Westeford »

Per K Grok wrote: Thu Mar 28, 2019 1:53 am text_align 0.5
My mistake. I probably should've posted my attempts and errors first.

Code: Select all

add Text ( "{size=50}[sta]", slow=True ) xcenter 0.5 text_align 0.5

#Error
File "game/trialscreens.rpy", line 683: u'text_align' is not a keyword argument or valid child for the add statement.
    add Text ( "{size=50}[sta]", slow=True ) xcenter 0.5 text_align 0.5                                                           

Code: Select all

add Text ( "{size=50}[sta]" xalign 0.5, slow=True ) xcenter 0.5

#Syntax Error

Code: Select all

add Text ( "{size=50}[sta]", slow=True, text_align 0.5 ) xcenter 0.5

#Syntax Error

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: add Test center text?

#4 Post by Per K Grok »

Westeford wrote: Thu Mar 28, 2019 3:39 am
Per K Grok wrote: Thu Mar 28, 2019 1:53 am text_align 0.5
My mistake. I probably should've posted my attempts and errors first.

Code: Select all

add Text ( "{size=50}[sta]", slow=True ) xcenter 0.5 text_align 0.5

#Error
File "game/trialscreens.rpy", line 683: u'text_align' is not a keyword argument or valid child for the add statement.
    add Text ( "{size=50}[sta]", slow=True ) xcenter 0.5 text_align 0.5                                                           

Code: Select all

add Text ( "{size=50}[sta]" xalign 0.5, slow=True ) xcenter 0.5

#Syntax Error

Code: Select all

add Text ( "{size=50}[sta]", slow=True, text_align 0.5 ) xcenter 0.5

#Syntax Error

I was a bit hasty too. Didn't register that you where using text as a displayable.
I think this might work.

Code: Select all

add Text ( "{size=50}[sta]", text_align=0.5, slow=True) xcenter 0.5

User avatar
Westeford
Regular
Posts: 151
Joined: Mon Jun 19, 2017 4:43 pm
Completed: 12 Hours to Die
Projects: Project Premonition
itch: westeford
Location: United States
Contact:

Re: add Test center text?

#5 Post by Westeford »

Per K Grok wrote: Thu Mar 28, 2019 2:00 pm

Code: Select all

add Text ( "{size=50}[sta]", text_align=0.5, slow=True) xcenter 0.5
It works!
You're awesome, thank you so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]