Page 1 of 1

How to prevent mouse click skipping during dialogue.

Posted: Tue Jun 08, 2021 2:50 pm
by BrumaDev
I've looked around the forum, the cookbook and the documentation and while I found a couple of answers, they're all over 10 years old, and since then renpy has changed so much that it looks like the code in said links don't apply anymore.

Basically the question is this: How can I prevent the player from skipping the dialogue by mouseclick when a character is still speaking?
The latest link I found is this one: viewtopic.php?t=23463. There, user Elmiwisa presents a solution that looks like it works, by adding the blocks

Code: Select all

    if _preferences.text_cps==0:
        on "show" action dismiss_control.allow_dismiss
    else:
        on "show" action dismiss_control.block_dismiss
        timer dismiss_control.calculate_time(what,_preferences.text_cps) repeat False action dismiss_control.allow_dismiss
    on "hide" action dismiss_control.allow_dismiss
and

Code: Select all

class DismissControl:
        def __init__(self):
            self.dismissable=True
            config.say_allow_dismiss=self.dismiss_check
            return
        def allow_dismiss(self):
            self.dismissable=True
            return
        def block_dismiss(self):
            self.dismissable=False
            return
        def dismiss_check(self):
            return self.dismissable
        def calculate_time(self,what,cps):
            if cps==0:
                return 0.01
            else:
                return (float)(len(what))/(float)(cps)+0.01
    dismiss_control=DismissControl()
to the screens.rpy file.
However, when I try to replicate the result, I get several statement and end of line expected errors for the first part. I tried including it on an init python block, but then other different kinds of erros pop up. Can someone with more knowledge about this review these blocks and find out what's wrong? Pehaps some kind of syntax changed since 2013 that I'm not aware.