Dialogue callbacks

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
kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Dialogue callbacks

#1 Post by kivik »

Is there a way I can hook to the dialogue messages (the what) anytime a line of dialogue is spoken by any character?

I tried editing the say screen and get it to process the what value and show another screen with data in it, not realising that the screen seems to get triggered on redraw (I assume) so it's called numerous times and only 1 out of 4 times would it have the dialogue content, rendering my attempt a failure.

I basically want a way of running a regex through every dialogue, picking out specific words when available, and getting them to show up on a separate screen. I've got the regex part down, it's literally just processing the dialogues when they occur that I can't figure out.

I don't know if Character callbacks can be an option, since I don't know how to grab the dialogue on the callback.

Many thanks for help in advance!

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Dialogue callbacks

#2 Post by gas »

Wild guess, but probably the start interaction callback is something to try.
You don't have to check when text is rendered, but when the interaction is back to users after rendering.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

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

Re: Dialogue callbacks

#3 Post by Ocelot »

You can extend an ADVCharacter class to do whatever you want when it is called and then defer to parent class behavior, then define all characters to be your new type.
< < insert Rick Cook quote here > >

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Dialogue callbacks

#4 Post by kivik »

Thanks guys, I've been having a look at the config callbacks, but I'm stumped as to how to work with them.

What I want to accomplish is being able to call a function for every dialogue, and be able to use the what value / the text in the dialogue and process it, before showing a new screen if there are valid outputs.

Looking at the callbacks they either say list functions without parameters, or in the case of config.say_arguments_callback mentions returning a pair of values.

Just to clarify I'm not actually that familiar with this level of Renpy, I've seen character callbacks being mentioned before but I could barely understand them, so this is a little beyond me, so I may need some example code if possible .__.U

Sorry and thanks for your help!

Post Reply

Who is online

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