[SOLVED] Applying styles to multiple screen texts?

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
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

[SOLVED] Applying styles to multiple screen texts?

#1 Post by Enchant00 »

It's probably something I mislooked, but is there a way to simplify the applying of text styles into one line than applying like the one below?

Code: Select all

vbox:
    area (400, 300, 100, 100)
    text 'Sample text 1' style 'sample text'
    text 'Sample text 2' style 'sample text'
    text 'Sample text 3' style 'sample text'
    text 'Sample text 4' style 'sample text'

style sample text:
    size 15
    bold True
Last edited by Enchant00 on Sun Jul 14, 2019 6:41 am, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3097
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Applying styles to multiple screen texts?

#2 Post by Alex »

Haven't tested it myself, but try to set style prefix for vbox (like it made for preferences screen - https://www.renpy.org/doc/html/screen_s ... references) and create proper styles for text.
style_prefix
Provides a prefix to the style of this displayable and all of its children, ...
https://www.renpy.org/doc/html/style.ht ... nheritance
https://www.renpy.org/doc/html/screens. ... yle-prefix

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Applying styles to multiple screen texts?

#3 Post by Enchant00 »

Yeah, that seems to do the trick. Thanks!

For anyone else that's wondering how it's done:

Code: Select all

vbox:
    style prefix "sample" # name of the styles, in this case they all start with sample
    text 'Sample text 1' 
    text 'Sample text 2' 
    text 'Sample text 3' 
    text 'Sample text 4' 

style sample_text: # your style name used above in prefix + where you want it applied, so in this case it would be on text
    size 15
    bold True

style sample_vbox: # applies to the vbox
    area (400, 300, 100, 100)

Post Reply

Who is online

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