adjustable variables not reflecting change on live composite if defined in a style group

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
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

adjustable variables not reflecting change on live composite if defined in a style group

#1 Post by namastaii »

If I apply individual styles onto a text within live composite, it works. But I was hoping to shorten some text and apply everything into a style but I guess changing variables through a style doesn't work?

I'm just using Python for this.

For example,

Code: Select all

textsize = 25 #There would be a default here and in a screen, the variable is changed by the user which displays changes in the live composite

Code: Select all

def composite_example(st, at):
        return LiveComposite(
        (0, 0),
        (0, 0), Text("Just some text", size=(textsize)),
        ),.1
^ This has no issue. If I want to use a shortcut (because I'm using multiple style options), it doesn't reflect any changes into the live composite:

Code: Select all

style.user_text.size = textsize

Code: Select all

def composite_example(st, at):
        return LiveComposite(
        (0, 0),
        (0, 0), Text("Just some text", style="user_text"),
        ),.1
Is there any way to achieve this? Maybe syntax is off. I've tried with or without quotations, I've tried defining the styles a couple ways and it's not really showing up UNLESS I have just a simple number instead of the adjustable variable.

Code: Select all

style.user_text.size = 30
works fine but not really what I want obviously.

Will I just need to create a function for this instead?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: adjustable variables not reflecting change on live composite if defined in a style group

#2 Post by Remix »

Styles are built at init time and pretty much set in stone from that point on (short of changing language or expressly calling style.rebuild() which is Not advised as it takes a while to rebuild them all)

So, in essence, a variable or function call is likely the best approach here (depending where the user changes the values of course)
Frameworks & Scriptlets:

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: adjustable variables not reflecting change on live composite if defined in a style group

#3 Post by namastaii »

Yeah I will just be creative with a function I suppose:) shouldn't be too hard

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]