Character callbacks - "end" event not activating

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
computistxyz
Regular
Posts: 58
Joined: Thu Jul 10, 2014 8:35 am
Github: sjgriffiths
Location: Coventry/Norwich, UK
Contact:

Character callbacks - "end" event not activating

#1 Post by computistxyz »

I've got a global variable which essentially keeps track of whether or not a character is currently talking. All characters are set to the talking callback and the following code does indeed set the variable, which defaults to False at game start, to True when a character begins talking.

Code: Select all

def talking(event, **kwargs):
    global isTalking
        if event == "begin":
            isTalking = True
        elif event == "end":
            isTalking = False
However, the variable is never set to False. I'm not entirely sure why the "end" event never seems to be called, but I'm guessing it's something to do with the fact that the "end" event happens when the player dismisses the dialogue, by which time it's immediately set to True at the start of the next say statement.

Code: Select all

def talking(event, **kwargs):
    global isTalking
        if event == "begin":
            isTalking = True
        elif event == "slow_done":
            isTalking = False
I tried the above workaround, using "slow_done" instead; however, this means the variable is set to False over any {p} pause tag I might have in a say statement, whereas I only want it to be set to False at the very end of every box (like the default CTC behaviour).

Am I right re. the "end" event behaviour? Could anyone offer advice about a potential workaround either with the first example method or the second using "slow_done"?
computer scientist | programmer | game developer | writer | editor/proofreader

Check out my technical blog, computist.xyz

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: Character callbacks - "end" event not activating

#2 Post by shivanshs9 »

How about using this:

Code: Select all

def talking(event, **kwargs):
    global isTalking
        if event == "begin":
            isTalking = True
        elif event == "show_done":
            isTalking = False
        elif event == "end":
            isTalking = False
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

User avatar
computistxyz
Regular
Posts: 58
Joined: Thu Jul 10, 2014 8:35 am
Github: sjgriffiths
Location: Coventry/Norwich, UK
Contact:

Re: Character callbacks - "end" event not activating

#3 Post by computistxyz »

shivanshs9 wrote:How about using this:

Code: Select all

def talking(event, **kwargs):
    global isTalking
        if event == "begin":
            isTalking = True
        elif event == "show_done":
            isTalking = False
        elif event == "end":
            isTalking = False
Same problem - the "end" event doesn't set it to False, most likely because I think "end" occurs when the user dismisses the dialogue.

Also, I'm using a text speed, so "show_done" just activates straight away.
computer scientist | programmer | game developer | writer | editor/proofreader

Check out my technical blog, computist.xyz

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

Re: Character callbacks - "end" event not activating

#4 Post by trooper6 »

In my game, I have a character who is a slow talking old man barber.
For some dialogue, I want to give the player the ability to interrupt the barber by pressing the "Interrupt" button.

So I needed the ability to turn on the Interrupt button when the old man was talking, but not the main character.

So I created a callback that turns on the can_interrupt boolean when the barber starts talking, but turns it off when the slow text is done. I did it (more or less) like this:

Code: Select all

    def arrow(event, **kwargs):
        global can_interrupt
        global can_cont
        if event == "show" or event == "begin":
            can_interrupt = True
            can_cont = False
        if event == "slow_done" or event == "end":
            can_interrupt = False
            can_cont = True
            renpy.restart_interaction()
I cut out some elements that dealt with adjusting some other variables, but this is basically it...and it works...so maybe cut out the elif/else and just make it two if statements?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
computistxyz
Regular
Posts: 58
Joined: Thu Jul 10, 2014 8:35 am
Github: sjgriffiths
Location: Coventry/Norwich, UK
Contact:

Re: Character callbacks - "end" event not activating

#5 Post by computistxyz »

trooper6 wrote:I cut out some elements that dealt with adjusting some other variables, but this is basically it...and it works...so maybe cut out the elif/else and just make it two if statements?
Thanks for the example. As far as I can tell, it achieves near enough the same thing as my second attempt; it works except it still counts a timed {p} pause as a 'no longer talking', whereas ideally it should only throw up False at the very end of the current dialogue box.
computer scientist | programmer | game developer | writer | editor/proofreader

Check out my technical blog, computist.xyz

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]