character_callback vs. say_arguments_callback

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
trooper6
Lemma-Class Veteran
Posts: 3265
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

character_callback vs. say_arguments_callback

#1 Post by trooper6 » Thu Jul 12, 2018 1:51 am

So both the character_callback and the say_arguments_callback take arguments associated with a character speaking and does stuff with that info.

character_callback documentation: https://www.renpy.org/doc/html/characte ... -callbacks
say_arguments_callback documentation: https://www.renpy.org/doc/html/config.h ... s_callback

When would you want to choose one versus the other?
What are the advantages of one and of the other?

It seems one difference is that character_callback is automatically passed the event variable, while the say_arguments_callback is automatically passed the who variable.

One of the reasons I ask is because I have a character callback that decides if the slow_talking character can be interrupted or not. With callback variable 1, it cannot be interrupted. With callback variable 2, it can be interrupted.
Now, I also want it to be that this character can have a long text where for the first half of the text it can't be interrupted, but for the second half of the conversation it can be interrupted.

Currently, I have a function like so:

Code: Select all

init -1 python:
    def splitlines(what, **kwargs):
        what1, what2 = what.split("~")
        w1 = what1 + "{color=#000}{cps=0}" + what2 + "{/color}{/cps}{nw}"
        w2 = what1 + "{fast}" + what2
        b1(w1, cb_num=0) #Note: in the character definition, 0 is the default callback value
        b1(w2, cb_num=1)
That I can call like so:

Code: Select all

label start():
    "The game starts."
    b3 "Right now you can't interrupt this character, because it's default callback variable is 0."
    b3 "Now I want you to be able to interrupt this character, so I change the callback variable for this line." (cb_num=1)
    $splitlines("The callback variable is 0, which means you can't interrupt. ~Now the callback variable is 1, which means you can interrupt.")
So all that works fine...but...I feel like there might be a better way of doing this that might involve the say_argument_callback? Or something?
Also, the problem with the splitlines function is that it only works on the character b1. But if I can't switch image tags mid-game, then I'm going to have two different characters who would be accessing this function (b1 and b2). So...it would be great if I could catch a who in this function...which say_arguments_callback would do, no? But I don't know if you can use say_arguments_callback to trigger the two different says like my function does.

Thoughts on how to accomplish this? Or should I just put this splitting function in the say screen?
ETA: Actually, I don't quite see how modifying the say screen would let me to change the call back variable...so I'm really hoping the say_arguments_callback might be able to do this.
A Close Shave:
*Last Thing Done (Jul 10): Converted LiveComposite Sprites to LayeredImages
*Currently Doing: Trying to work out the transition thing for two character using the same sprite and try to figure out how to redo my multi-barber thing...i.e. see if there is a way to re_do my character callbacks
*First Next thing to do: Rebuild the project with the new RenPy (i.e. with gui.rpy present.), this will mean making some gui art now that I don't have access to the old theme.
*Next thing to do: Code in all the sprite emotion and camera movement for Close Shave Sprite Sections
*Other Thing to Do: Code in all CG and special animation stuff
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
PyTom
Ren'Py Creator
Posts: 15152
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: character_callback vs. say_arguments_callback

#2 Post by PyTom » Thu Jul 12, 2018 11:46 pm

I don't really get what you're trying to do here. It might be similar to the new monologue mode introduced in 7.0.1, in which case I'd suggest using that.

As for the variables, they let you customize different parts of the say process. You could also store the arguments passed to say_arguments_callback elsewhere, so you can access them in screens and so on.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
trooper6
Lemma-Class Veteran
Posts: 3265
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: character_callback vs. say_arguments_callback

#3 Post by trooper6 » Fri Jul 13, 2018 12:18 am

The monologue mode isn't it. I'll just change the standalone function to also take a who argument.

I would love to see a Patreon article that explores in more detail the diversity of what all can be done with the say_arguments_callback and why you'd use it.
The example code just changes the what_color of the speaker...which can be done without using a config.say_arguments_callback. I feel like the callback has got to be able to do some pretty cool stuff.
A Close Shave:
*Last Thing Done (Jul 10): Converted LiveComposite Sprites to LayeredImages
*Currently Doing: Trying to work out the transition thing for two character using the same sprite and try to figure out how to redo my multi-barber thing...i.e. see if there is a way to re_do my character callbacks
*First Next thing to do: Rebuild the project with the new RenPy (i.e. with gui.rpy present.), this will mean making some gui art now that I don't have access to the old theme.
*Next thing to do: Code in all the sprite emotion and camera movement for Close Shave Sprite Sections
*Other Thing to Do: Code in all CG and special animation stuff
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
PyTom
Ren'Py Creator
Posts: 15152
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: character_callback vs. say_arguments_callback

#4 Post by PyTom » Fri Jul 13, 2018 12:38 am

The problem is it's more a sort of feature that's there because people might use it. There's a lot of things you can do, but they're mostly forms of passing arguments to a screen, something like that.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: MaydohMaydoh