Character(kind=centered) not working? [workaround found]

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
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Character(kind=centered) not working? [workaround found]

#1 Post by noeinan »

Previously I have used "centered" to make text appear in the middle of the screen outside of the textbox. My code looked like this:

Code: Select all

centered "{b}{size=+12}{color=#003C78}Second Week Plan: [week02]{/color}{/size}{/b}"
Then I decided I needed an outline to make my text look nice on different backgrounds, and it was a pain to have that entire line every time I needed my centered text. So I decided to use a defined character instead:

Code: Select all

define wk = Character(None, kind = centered, what_outlines = [(4, "#003C78", 0, 0)], what_bold = True, what_size = 34)
And it all works except centered. For some reason, if I try to use kind = centered, as shown in this documentation under Special Characters: http://www.renpy.org/doc/html/dialogue.html

I just end up getting this error message:

Code: Select all

NameError: name 'centered' is not defined
Any ideas? Is this code just old and I need a newer version? Thanks!
Last edited by noeinan on Sat Feb 08, 2014 1:11 pm, edited 1 time in total.
Image

Image
Image

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Character(kind=centered) not working?

#2 Post by Asceai »

For whatever reason, 'centered' is defined really late by renpy (it's in an init 1400 block.) So all I can suggest is shoving

Code: Select all

$wk = Character(None, kind = centered, what_outlines = [(4, "#003C78", 0, 0)], what_bold = True, what_size = 34)
into your script somewhere not in an init block.
Unfortunately this means updating wk will not reflect in any saves because the definition will be stored in the save files (and rollback) so it's not ideal. A better thing is probably to just steal the definition of centered..

Code: Select all

centered = Character(None, what_style="centered_text", window_style="centered_window")
Last edited by Asceai on Fri Feb 07, 2014 3:15 am, edited 1 time in total.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Character(kind=centered) not working?

#3 Post by noeinan »

Hrm. I actually tried that before I used "define" and got the same error. :/ (Not in an init block, either...)
Image

Image
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Character(kind=centered) not working?

#4 Post by nyaatrap »

For whatever reason, 'centered' is defined really late by renpy (it's in an init 1400 block.)
I guess it's a bug? I don't know any reason why it's 1400.
Simple solution would be use init 9999 python. You may also use init 9999 define in ren'py 6.17.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Character(kind=centered) not working?

#5 Post by noeinan »

So, something like this?

Code: Select all

init 9999 python:
    $wk = Character(None, kind = centered, what_color = "#003C78", what_outlines = [(3, "#FFFFFF", 0, 0)], what_bold = True, what_size = 34)
I think my syntax might be off, though.
Image

Image
Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Character(kind=centered) not working?

#6 Post by nyaatrap »

$ is one line python. You don't need to use $ inside of a python block.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Character(kind=centered) not working?

#7 Post by noeinan »

Oh, got it! Thanks, it's working now.
Image

Image
Image

chaos-dark-lord
Newbie
Posts: 8
Joined: Sun May 07, 2017 3:59 pm
Deviantart: chaos-dark-lord
Contact:

Re: Character(kind=centered) not working? [workaround found]

#8 Post by chaos-dark-lord »

Great post, I actually managed to make this work... well, almost. (I get a shadow adv textbox before the centered text appears)

This shows a centered character:

First, at the top of the script doc where I declare my viables I use this

Code: Select all

init 9999 python:
    na = Character(None, kind = centered, what_color="#E6E6E6", who_outlines=[ (1, "#000000")])
Then in whatever label Im in this makes this centered text appear over a 60% transparency black window sized image that imitates the blackened background of the NVL mode

Code: Select all

    

if tut == "tutorial":
        hide text
        show transparency
        with Dissolve(.3)
        na "Centered customized text"
        hide transparency
        with Dissolve(.3)
That works wonders when you wanna show a message on top of everything. Like for a tutorial when you pause the action to describe something.

BUT....

The problem I have is that right before the centered text shows up, just while the transparency is appearing, even though I use 'hide text' , A shadow ADV textbox appears briefly (like .4 secs). No idea why and no idea on how to prevent it from happening.

Does anyone knows how to solve it?

Post Reply

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot]