Predicting the next speaking character using scry/"Character is typing..."

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
Gabmag
Regular
Posts: 76
Joined: Wed Sep 19, 2018 10:49 pm
Completed: A Date with Death, The Divine Speaker, start;again, Amelie, The Sun and the Moon
Projects: Dreambound
Organization: Two and a Half Studios
IRC Nick: Gabmag
Location: Australia
Contact:

Predicting the next speaking character using scry/"Character is typing..."

#1 Post by Gabmag »

Hello everyone!

I'm currently working on a chatsim, and have edited the NVL menu to hold the "messaging client" part of the game. All works fine and as expected, but I was considering adding a "XYZ is typing..." indicator.

I actually have got this mostly working using renpy.scry(), but I find that it doesn't update fast enough. When it changes from one character to another typing, it lags behind a little, and won't update the variable for a couple of seconds, which makes it say "XYZ is typing..." when they aren't. When it changes from the player character back to the love interest typing, the typing indicator also doesn't appear UNTIL the message does.

Any suggestions? I've tried changing the timer around of course. If there's a better way to do the typing indicator, I'd be happy to hear it, too.

Code: Select all

init python:
    def getcurrentspeaker():
        scry = renpy.scry()
        store.grim_reaper_is_next = scry.who

screen nvl(dialogue, items=None):
    timer 0.5 action Function(getcurrentspeaker)
    window:
        style "nvl_window"

        has vbox:
            spacing gui.nvl_spacing

        viewport id "nvlscroll":
            area (0, -50, 1470, 750)
            yinitial 1.0
            mousewheel True

            
           vbox:
                for d in dialogue:
                    if d.who is not None:
                            hbox:
                                add message_icon xoffset 30 yoffset 3

                                text d.who:
                                    id d.who_id


                        text d.what:
                            id d.what_id

    if str(grim_reaper_is_next) == "Grim Reaper":
        text "[grim_reaper_name] is typing...":
            xalign 0.2 yalign 0.8
i make games sometimes, other times i cry.

User avatar
Kia
Eileen-Class Veteran
Posts: 1050
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Predicting the next speaking character using scry/"Character is typing..."

#2 Post by Kia »

The way I've handled it was by introducing an artificial pause, and calling a method in my phone class to mimic a typing animation

Code: Select all

$ nvl_phone.type("Ririn", [10, 20, 35])
It's tons of lines sprinkled between the dialogue, but you'll have full control over how it looks. Of course you can let the class calculate the duration of typing depending on the length of the dialogue too.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Predicting the next speaking character using scry/"Character is typing..."

#3 Post by _ticlock_ »

Gabmag wrote: Tue May 09, 2023 8:15 am Hello everyone!

I'm currently working on a chatsim, and have edited the NVL menu to hold the "messaging client" part of the game. All works fine and as expected, but I was considering adding a "XYZ is typing..." indicator.

I actually have got this mostly working using renpy.scry(), but I find that it doesn't update fast enough. When it changes from one character to another typing, it lags behind a little, and won't update the variable for a couple of seconds, which makes it say "XYZ is typing..." when they aren't. When it changes from the player character back to the love interest typing, the typing indicator also doesn't appear UNTIL the message does.

Any suggestions? I've tried changing the timer around of course. If there's a better way to do the typing indicator, I'd be happy to hear it, too.
The problem is due to the timer. It likely creates all the problems. Instead, you can use, for example, a transform.

I also did not understand why you get the current speaker. Is it your idea to predict the next character?

I like the idea of Kia, but if you are looking for a solution without additional lines, here is a possible example:

Code: Select all

init python:
    def nextspeaker():
        scry = renpy.scry()
        scry.next() # If you want to predict the next character
        return scry.who
Just a basic delay transform. You can improve it to mimic a messenger effect when someone is typing.

Code: Select all

transform nvl_typing:
    alpha 0.0
    pause 0.5
    linear 0.3 alpha 1.0

Code: Select all

screen nvl(dialogue, items=None):
    window:
        ...

    # next_who = nextspeaker()
    if next_who:
        text "[next_who] is typing ..." at nvl_typing:
            xalign 0.2 yalign 0.8

User avatar
Gabmag
Regular
Posts: 76
Joined: Wed Sep 19, 2018 10:49 pm
Completed: A Date with Death, The Divine Speaker, start;again, Amelie, The Sun and the Moon
Projects: Dreambound
Organization: Two and a Half Studios
IRC Nick: Gabmag
Location: Australia
Contact:

Re: Predicting the next speaking character using scry/"Character is typing..."

#4 Post by Gabmag »

Kia wrote: Fri May 12, 2023 2:12 am The way I've handled it was by introducing an artificial pause, and calling a method in my phone class to mimic a typing animation

Code: Select all

$ nvl_phone.type("Ririn", [10, 20, 35])
It's tons of lines sprinkled between the dialogue, but you'll have full control over how it looks. Of course you can let the class calculate the duration of typing depending on the length of the dialogue too.
Thank you! I did consider doing it manually like this, but I think I'd probably end up cutting the feature rather than adding this in between every single line, as the whole game is texting. Still, I appreciate the response!
i make games sometimes, other times i cry.

User avatar
Gabmag
Regular
Posts: 76
Joined: Wed Sep 19, 2018 10:49 pm
Completed: A Date with Death, The Divine Speaker, start;again, Amelie, The Sun and the Moon
Projects: Dreambound
Organization: Two and a Half Studios
IRC Nick: Gabmag
Location: Australia
Contact:

Re: Predicting the next speaking character using scry/"Character is typing..."

#5 Post by Gabmag »

_ticlock_ wrote: Fri May 12, 2023 11:24 am
Gabmag wrote: Tue May 09, 2023 8:15 am Hello everyone!

I'm currently working on a chatsim, and have edited the NVL menu to hold the "messaging client" part of the game. All works fine and as expected, but I was considering adding a "XYZ is typing..." indicator.

I actually have got this mostly working using renpy.scry(), but I find that it doesn't update fast enough. When it changes from one character to another typing, it lags behind a little, and won't update the variable for a couple of seconds, which makes it say "XYZ is typing..." when they aren't. When it changes from the player character back to the love interest typing, the typing indicator also doesn't appear UNTIL the message does.

Any suggestions? I've tried changing the timer around of course. If there's a better way to do the typing indicator, I'd be happy to hear it, too.
The problem is due to the timer. It likely creates all the problems. Instead, you can use, for example, a transform.

I also did not understand why you get the current speaker. Is it your idea to predict the next character?

I like the idea of Kia, but if you are looking for a solution without additional lines, here is a possible example:

Code: Select all

init python:
    def nextspeaker():
        scry = renpy.scry()
        scry.next() # If you want to predict the next character
        return scry.who
Just a basic delay transform. You can improve it to mimic a messenger effect when someone is typing.

Code: Select all

transform nvl_typing:
    alpha 0.0
    pause 0.5
    linear 0.3 alpha 1.0

Code: Select all

screen nvl(dialogue, items=None):
    window:
        ...

    # next_who = nextspeaker()
    if next_who:
        text "[next_who] is typing ..." at nvl_typing:
            xalign 0.2 yalign 0.8
Thanks for that! The getcurrentspeaker is just poor naming on my part.

I've implemented your idea, but unfortunately it leads to the same issue as my previous code. After the player characters message is sent, no matter who is saying the next line, it will say "player_name" is typing. Fortunately I don't want it to say when the player is typing, so I set it to only show when the love interest is typing - but the problem with the player character remains in that NOTHING will show after the player characters message, then the love interests message will appear. From then on it will work, but when it switches between characters nothing will show.

It's the same the other way around - it will show "love interest" is typing, then that will disappear, then the player options come up. I believe it's something to do with menus and choices.

Thank you very much for your help, but I think I'll probably just scrap the idea or come back to it later!
i make games sometimes, other times i cry.

Post Reply

Who is online

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