[Solved] Can we use lists and variables inside of 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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

[Solved] Can we use lists and variables inside of styles?

#1 Post by henvu50 »

Can we use lists and variables inside of styles?

This works:

Code: Select all

screen test():
   textbutton "yo":
     text_font "fonts" + font_files[cycleFontIndex]
     action NullAction()
But this doesn't work, it says font_files is not defined, even though it works up above.

Code: Select all

style test33:
    font "fonts" + font_files[cycleFontIndex]
Anyone know why? Are we not allowed to use a list or variable in a style?
Last edited by henvu50 on Sun Jul 25, 2021 3:28 am, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Can we use lists and variables inside of styles?

#2 Post by hell_oh_world »

you can use variables as long as the variables are defined before the style is called for parsing. it's just a matter of init order.
even though you make it work, your styles won't be dynamic since styles are only called once during initialization.
style the displayable in the screen itself if you want to make it dynamic.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2376
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Can we use lists and variables inside of styles?

#3 Post by Ocelot »

hell_oh_world wrote: Sun Jul 25, 2021 2:10 am even though you make it work, your styles won't be dynamic since styles are only called once during initialization.
You can change and rebuild styles during gameplay. Though simply not messing with style definitions and changing style based on some variable is still better.
< < insert Rick Cook quote here > >

Post Reply

Who is online

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