defining style via python with different parent than style.default

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
svatem1
Newbie
Posts: 5
Joined: Thu Sep 29, 2022 1:34 pm
Contact:

defining style via python with different parent than style.default

#1 Post by svatem1 »

I have the following code:

Code: Select all

init offset = -1

style default:
    properties gui.text_properties()
    language gui.language
    color "#ff0000"

style whatever:
    properties gui.text_properties()
    language gui.language
    color "#ff0000"

init 1 python:
    style.example = Style(style.default)
This code works without any problems. If i want to use style.whatever as the parent of my example style:

Code: Select all

init 1 python:
    style.example = Style(style.whatever)
, the code fails with "style whatever doesn't exist" traceback. In the documentation, I found, that style statement is run during init 0 phase, if not stated otherwise. Also, if I delete style default definition and use style.default as the parent, it still works. What exactly is going on here and how can I use my own style as parent?

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

Re: defining style via python with different parent than style.default

#2 Post by Ocelot »

What happens if you use 5 as init priority for Python code?
< < insert Rick Cook quote here > >

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: defining style via python with different parent than style.default

#3 Post by enaielei »

Don't do it in python.

Code: Select all

style example is whatever:
   # properties

svatem1
Newbie
Posts: 5
Joined: Thu Sep 29, 2022 1:34 pm
Contact:

Re: defining style via python with different parent than style.default

#4 Post by svatem1 »

Ocelot wrote: Thu Sep 29, 2022 2:02 pm What happens if you use 5 as init priority for Python code?
same error

svatem1
Newbie
Posts: 5
Joined: Thu Sep 29, 2022 1:34 pm
Contact:

Re: defining style via python with different parent than style.default

#5 Post by svatem1 »

enaielei wrote: Thu Sep 29, 2022 2:05 pm Don't do it in python.

Code: Select all

style example is whatever:
   # properties
I'll try to stay out of python as much as possible, I just found random example of something that looked like I could use, started modifying it and this was the error I ran into

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

Re: defining style via python with different parent than style.default

#6 Post by Ocelot »

Try Style("whatever") instead. If it fails too, use default style and call .set_patent later.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]