Continuing to need help with screens and styles

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
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Continuing to need help with screens and styles

#1 Post by YamiiDenryuu »

I'm using the show text function to make some messages appear in my game, but as it is it looks... terrible.
pythonw 2014-07-17 19-44-08-31.png
What I can find about it talks about using styles, so there's apparently some way to change how it looks, but I can't seem to figure it out. What I'd like is to make it look something like the menu options- just add a box with a simple border behind the text. How can I do that? Is there a better function I could be using?
Last edited by YamiiDenryuu on Thu Aug 21, 2014 6:34 pm, edited 2 times in total.

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

Re: How to make "show text" look nicer

#2 Post by Asceai »

show text is mega limited (and also undocumented =P). I'd suggest using a screen, then you can do what you want.

Code: Select all

screen message:
    default txt = ""
    frame align (0.5, 0.5):
        text txt
You can then style the frame and text as you like with window and text style properties just like you style anything in a screen.
You can then show messages in the script using:

Code: Select all

    show screen message(_transient=True, txt="PLACEHOLDER REPLY GOES HERE")
in the place of 'show text'
_transient=True puts the screen on the "transient" layer so the message disappears with the next click.

User avatar
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Re: How to make "show text" look nicer

#3 Post by YamiiDenryuu »

Okay, I'll try that out. Thanks!

User avatar
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Re: How to make "show text" look nicer

#4 Post by YamiiDenryuu »

Oh... kay, I almost succeeded in creating the box I wanted, but then suddenly I broke Ren'py.
bork renpy.png
Before that, I was getting the usual type of error messages, about "mesbox" not being defined with this code:

init:
$ mp = MultiPersistent("medukameguca")
$ style.create("mesbox", default)
$ style.mesbox.textalign = 0.5
$ style.mesbox.background = "#000"

screen message(style=mesbox):
default txt = ""
frame align (0.5, 0.5):
text txt


The error was occurring on the line with "screen message(style=mesbox)".

The new supererror happened when I decided to try indenting the screen message block another tab to line up with the init block (my code is really badly organized... but that's a separate problem), and persisted even after I undid that. Please send help.

Okay, removing the init block fixed the crazy error, at least. So what am I doing wrong?
u wot m8

User avatar
fluxus
Regular
Posts: 133
Joined: Thu Jun 19, 2014 8:06 am
Projects: Animal Anaesthesia (a teaching game)
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#5 Post by fluxus »

Well, badly organized code and super-errors are never separate problems :)

In order to get good advice on tab placement though (and coding style in general), you need to use the code tags when copy-pasting your program code.

Code: Select all

[code]
Your:
    code here
[/code]

By the way you can do

Code: Select all

init python:
    code
    code
instead of

Code: Select all

init:
    $ code
    $ code

User avatar
fluxus
Regular
Posts: 133
Joined: Thu Jun 19, 2014 8:06 am
Projects: Animal Anaesthesia (a teaching game)
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#6 Post by fluxus »

Hmm. I'm only beginning to look into styles myself, but, it looks like

Code: Select all

style my_text is text:
    size 40
is the standard way of defining a new style?

In your example that would be

Code: Select all

style mesbox is default:
    align 0.5
I'm not really sure about this, and haven't tried it out myself. Currently I'm trying to find out for myself how to find out where to fetch the colours defined by the theme so that whatever I define things as, a theme change won't break everything :]

Have you looked at http://www.renpy.org/doc/html/style.html though?

User avatar
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#7 Post by YamiiDenryuu »

@fluxus: Well, I used the tag because it said it was for code, but I guess [code] is the better tag. So let me try that again:

[code]init:
$ mp = MultiPersistent("medukameguca")
$ style.create("mesbox", default)
$ style.mesbox.textalign = 0.5
$ style.mesbox.background = "#000"

screen message(style=mesbox):
default txt = ""
frame align (0.5, 0.5):
text txt[/code]

As for the code I used, I found it on one of the Renpy wiki pages... I'll try your code next, though.
u wot m8

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#8 Post by xela »

Code: Select all

style mesbox_frame:
    is default
    align (0.5, 0.5)
    background "#000" # Or path to a pretty background
    
style mesbox_text:
    is text
    align (0.5, 0.5)

screen message(txt):
    frame:
        style_group "mesbox"
        text txt

label start:
    show screen message("I am a Centered Text!")
    "Meow"
Add _transient=True if you want it to disappear with the next interaction. This is how it's done in modern Ren'Py if you want to use styles.
Like what we're doing? Support us at:
Image

User avatar
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#9 Post by YamiiDenryuu »

Awesome, thanks! It looks like it'll be easy to change the text color now, too, which is the last thing I needed to fix... I'll try that out tomorrow. (:
u wot m8

User avatar
fluxus
Regular
Posts: 133
Joined: Thu Jun 19, 2014 8:06 am
Projects: Animal Anaesthesia (a teaching game)
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#10 Post by fluxus »

xela: Ah.. so that's how you're supposed to use it. It makes more sense now. I think ^.^

User avatar
YamiiDenryuu
Newbie
Posts: 9
Joined: Sun Mar 23, 2014 11:07 pm
Projects: meduka meguca: the loop of infinity
Contact:

Re: UPDATE: Broke Ren'py with screens and styles. ):

#11 Post by YamiiDenryuu »

pythonw 2014-08-20 20-54-26-91.png
... This doesn't look very nice. Gotta figure out how to get the nice border and stuff on it. But at least I'm on the right track.

Could I make it start with the theme I'm using for the rest of the game (Diamond/Dreamscape) instead of default? That'd go a long way towards making it match the rest of the game and not look like poo.


Incidentally, I should probably open another thread asking for tips on organizing my code, especially the initial stuff (character declarations, variables, etc). I don't know what goes in an init block, what goes after label start and what just kinda hangs out there. :/
u wot m8

User avatar
fluxus
Regular
Posts: 133
Joined: Thu Jun 19, 2014 8:06 am
Projects: Animal Anaesthesia (a teaching game)
Contact:

Re: Continuing to need help with screens and styles

#12 Post by fluxus »

I haven't really learned how to do things with styles as yet.
One way to costumize the textbox, though, is to draw a graphical frame (with pretty borders) and make the textbox use that as a background. There's a guide on how to do that here.

As for code organization, init sections are generally where you prepare your data and variables, making them ready to be used by the rest of the game.

Labels are generally code that describes a scene. It's not always true that one scene equals one label, but it's a good way to organize things for the most part.

All code organization is about making the code understandable. For the interpreter (Ren'Py, Python), for yourself, and for others.
If you have a long, complicated section and can see a way to divide it into smaller, more understandable bits, it's a good idea to do so.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Draida