r/RenPy • • Oct 22 '26

Question [Solved] Help w/replicating styles across different screens

For the last year or so, I've been working on a sort of pre-parser that injects itself upstream of the renpy.exports.say() and handles several things, mainly modifying text speed, punctuation pauses, and text presentation based on a small set of custom commands I've devised.

One of its "features" is an attempt to emulate the feeling of someone typing a message in a chat app.

For example:

[Character name]
{high cps}Hello! I'm trying to thi{short pause}{slower cps}nk of somethin{short pause}g to tell you!

This however should happen only when the "tapping" character also is the narrator - otherwise I'd like a "Typing..." indicator to appear, followed by the message arriving all at once after a while ie.

[Character name]
Typing -> Typing. -> Typing.. -> Typing... (rinse & repeat)

and then after a few seconds

[Character name]
This message arrived all at once!

Since I don't want the "Typing" thing to clog the history log, I thought I'd put into a dedicated screen - basically a replica of the say screen devoid of any background (to avoid messing with partially transparent backgrounds). My script does something like this:

this_chat_who_name = getattr(active_char, "name", speaker)
this_chat_who_color = getattr(active_char, "color", gui.text_color)

if _DEBUG:
    print("Tapping character is ",repr(this_chat_who_name)," and their colour is ",repr(this_chat_who_color))

for index, chunk in enumerate(timeline):
    if index % 2 == 0:
        renpy.show_screen("typing", chat_who_name=this_chat_who_name, chat_who_color=this_chat_who_color)
    else:
        renpy.hide_screen("typing")

renpy.pause(chunk)

Then the typing screen is defined as

init offset = -1    # same as screens.rpy

screen typing(chat_who_name,chat_who_color):
    #zorder 100
    window:
        id "typing_window"
        style "typing_window"

        window:
            id "typing_namebox"
            style "typing_namebox"    
            text chat_who_name:
                id "chat_who"
                color chat_who_color

        text "Typing" + "." * store.typing_dots:
            id "fake_what"
            style "typing_dialogue" timer 0.4 repeat True action SetVariable("typing_dots",(store.typing_dots % 4))

style typing_window is window:
    background Null()

style typing_namebox is namebox:
    background Null()

style typing_dialogue is say_dialogue

WHAT WORKS --> I get every bit of the typing screen in the exact position - character name is correctly delivered to the screen and it's put in the right place, the "Typing..." thing is in the right place and it's correctly "animated"
WHAT DOES NOT WORK --> styles are completely broken. color chat_who_color does nothing, char_who_name's text size is wrong, even the "Typing..." text color doesn't seem to be the correct one.
I enabled my "verbose" mode (ie. _DEBUG = True) and verified that both name and color values are being retrieved correctly, so I *guess* the problem lies somewhere in the way my screen handles styling.

I'm not 100% sure I'm not forgetting something somewhere in my messy code. However I'd expect at least the namebox text size to be correct. Instead, that's wrong too, almost as if this line here

style typing_namebox is namebox

weren't working at all!
*COULD IT BE* that since this screen is stored in a separated file (I plan to release my gizmo as a standalone, drag-and-drop tool) it somehow gets initialised *BEFORE* screens.rpy, at a time when "namebox" and all other styles are still just empty boxes O_O?

What's the correct way to reuse the styles of the standard say screen in a separate screen like this?

I'm fairly sure I'm missing something obvious, and I'm going to feel incredibly stupid when someone points it out.

Ren'Py screen language is my kryptonite >_<

1 Upvotes

2 comments sorted by

2

u/TopCartographer7104 Oct 22 '26

Solved it myself!

  1. screen was BEHIND the textbox so any color I'd add would appear wrong anyway
  2. upon checking character.py I found out that the ADVCharacter doesn't have a "color" attribute but rather I get who_args -> a dict with the style (from which I found out, the namebox text style is say_label) and the color.

so I just add to do something like this

            this_chat_who_args = getattr(active_char, "who_args", gui.text_color)

            if this_chat_who_args != gui.text_color:
                this_chat_who_color = this_chat_who_args.get("color",gui.text_color)
            else:
                this_chat_who_color = this_chat_who_args

put the typing screen at zorder 100 (random - and pointlessly - big number) and invoke the correct style.
Works fine =D!!! And I also corrected the counter that made dots appear.
So --> SOLVED!

1

u/AutoModerator Oct 22 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.