How is say_label overriding my custom style when I've already removed it from everywhere?

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
theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

How is say_label overriding my custom style when I've already removed it from everywhere?

#1 Post by theyeeguy »

I was trying to replicate the solution that was given to me in my previous post that changes the properties of text through a custom style. It turned out to be simple, specify a style "style_name" after the text. It then inherits the properties within the style_name, simple and makes sense.

I encountered another problem, however, when I tried to make a new project, this time just editing out parts of the code. I made a custom style, made the text who inherit properties from that style by adding style "nameStyle_t" and deleted the rest of the unused Say Screen code.

Code: Select all

screen say(who, what):

    window:

        if who is not None:

            window:
                id "name"
                style "nameStyle"
                text who id "who" style "nameStyle_t"

        text what id "what" style "sayStyle_t"


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0


## Make the namebox available for styling through the Character object.
init python:
    config.character_id_prefixes.append('nameStyle')



style window:
    xanchor 0
    yanchor 0
    xpos 410
    ypos 743

    background Image("gui/textbox.png")

style nameStyle:

    xanchor 0
    yanchor 0
    yoffset 15
    xoffset 40

style nameStyle_t:

    properties gui.text_properties("nameStyleGUI")

    size 78

style sayStyle:
    xanchor 0

style sayStyle_t:
    size 78
I ran it, and the display remained unchanged. I inspected the text and saw this:
Image

So then I replaced all instances of say_label in every text file in the game folder with nameStyle or even nameStyle_t, cleaned up some code relating to say_label. I even tried to change the default window properties just in case. Every single time, the text still inherited properties from this should be non existent say_label style. I am admittedly frustrated. It just doesn't make sense why it would completely ignore the style I assigned to it and instead follow something that does not even exist anywhere in the code.

In the middle of writing this post I was surprisingly able to find a "solution" by making say_label inherit nameStyle_t. Like so, in case some poor soul stumbles upon this problem in the future:

Code: Select all

style say_label is nameStyle_t
However, I am still at a loss as to why and how the nonexistent style say_label managed to override the custom style I assigned to it. I would greatly appreciate it if someone is able to answer my question.

jeffster
Veteran
Posts: 361
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: How is say_label overriding my custom style when I've already removed it from everywhere?

#2 Post by jeffster »

1. By default, as that text is in "say" screen, it receives a style like "say_text" or something.

(So it makes sense to just use that default name for its style.)

2. Another thing is that Ren'Py compiles our code into some "bytecodes", creating
(a) files .rpyc along with .rpy,
(b) and also some files in "cache" folder.

I wasted hours of debugging time trying to figure out some impossible errors, and then i found a way to "clean" them out by deleting all .rpyc files and everything in "cache" folder.

So I recommend you to do that in such cases. Only remember that after you had made a public release then releasing next versions you better have the old .rpyc from the previous release (to avoid some cases of incompatible saves).

theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

Re: How is say_label overriding my custom style when I've already removed it from everywhere?

#3 Post by theyeeguy »

1. I just don't understand how it is overriding the style I assigned to it even though it has been removed entirely.

2. Thank you very much for this, I'll keep it in mind when working with Ren'Py in the future.

So I have tried deleting everything in the cache folder as well as the .rpyc files, only problem now is the text still has say_label as its style even though I clearly have this in my code

Code: Select all

window:
                id "nameBox"
                style "nameBox_style"
                text who id "who" style "nameBox_style"
I even tried changing the NVL-mode properties (although I am not quite sure how these work yet)

Code: Select all

style nvl_label is nameBox_style
Even if say_label is "hard-coded" in Ren'Py to be the default property of the who text in the say screen, I just don't know why my custom style is ignored. I mean it worked on my previous project when I basically started both gui.rpy and screens.rpy from scratch, so there is definitely something somewhere in the code that dictates when to override a custom style. I just want to know where it is and how I can change it.

jeffster
Veteran
Posts: 361
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: How is say_label overriding my custom style when I've already removed it from everywhere?

#4 Post by jeffster »

I think you are right, it's hardcoded. I just fond this:

https://www.renpy.org/doc/html/screen_special.html#say
"who"
A text displayable, displaying the name of the speaking character. The character object can be given arguments that style this displayable.

"what"
A text displayable, displaying the dialogue being said by the speaking character. The character object can be given arguments that style this displayable. A displayable with this id must be defined, as Ren'Py uses it to calculate auto-forward-mode time, click-to-continue, and other things.
So it seems to be necessary for our ability to apply various styling properties to Character.

theyeeguy
Newbie
Posts: 12
Joined: Mon Sep 20, 2021 7:11 am
Contact:

Re: How is say_label overriding my custom style when I've already removed it from everywhere?

#5 Post by theyeeguy »

Thank you for the information, I appreciate it.

For now I'm just using the incomplete solution of making say_label inherit properties from my custom style to be able to get the results I want. I'm still curious however, as to how I managed to make it work last time without this workaround.

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

Re: How is say_label overriding my custom style when I've already removed it from everywhere?

#6 Post by Ocelot »

Try following:

Code: Select all

init -100 python:
    adv = Character(None, who_style='nameBox_style')
Or just create characters by doing somenting like char = Character('Character', who_style='nameBox_style')
< < insert Rick Cook quote here > >

Post Reply

Who is online

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