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.
-
henvu50
- Veteran
- Posts: 322
- Joined: Wed Aug 22, 2018 1:22 am
-
Contact:
#1
Post
by henvu50 » Sun Jul 25, 2021 1:36 am
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.
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#2
Post
by hell_oh_world » Sun Jul 25, 2021 2:10 am
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.
-
Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#3
Post
by Ocelot » Sun Jul 25, 2021 3:22 am
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 > >
Users browsing this forum: Google [Bot], span4ev