Page 1 of 1

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

Posted: Fri Feb 07, 2014 2:40 am
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!

Re: Character(kind=centered) not working?

Posted: Fri Feb 07, 2014 3:07 am
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")

Re: Character(kind=centered) not working?

Posted: Fri Feb 07, 2014 3:14 am
by noeinan
Hrm. I actually tried that before I used "define" and got the same error. :/ (Not in an init block, either...)

Re: Character(kind=centered) not working?

Posted: Fri Feb 07, 2014 6:06 am
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.

Re: Character(kind=centered) not working?

Posted: Fri Feb 07, 2014 5:15 pm
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.

Re: Character(kind=centered) not working?

Posted: Sat Feb 08, 2014 12:22 am
by nyaatrap
$ is one line python. You don't need to use $ inside of a python block.

Re: Character(kind=centered) not working?

Posted: Sat Feb 08, 2014 1:10 pm
by noeinan
Oh, got it! Thanks, it's working now.

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

Posted: Sun May 28, 2017 2:11 am
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?