Ejemplo n.º 1
0
    def at_repeat(self):
        """
        Call the event and reset interval.

        It is necessary to restart the script to reset its interval
        only twice after a reload.  When the script has undergone
        down time, there's usually a slight shift in game time.  Once
        the script restarts once, it will set the average time it
        needs for all its future intervals and should not need to be
        restarted.  In short, a script that is created shouldn't need
        to restart more than once, and a script that is reloaded should
        restart only twice.

        """
        if self.db.time_format:
            # If the 'usual' time is set, use it
            seconds = self.ndb.usual
            if seconds is None:
                seconds, usual, details = get_next_wait(self.db.time_format)
                self.ndb.usual = usual

            if self.interval != seconds:
                self.restart(interval=seconds)

        if self.db.event_name and self.db.number is not None:
            obj = self.obj
            if not obj.callbacks:
                return

            event_name = self.db.event_name
            number = self.db.number
            obj.callbacks.call(event_name, obj, number=number)
Ejemplo n.º 2
0
    def at_repeat(self):
        """
        Call the event and reset interval.

        It is necessary to restart the script to reset its interval
        only twice after a reload.  When the script has undergone
        down time, there's usually a slight shift in game time.  Once
        the script restarts once, it will set the average time it
        needs for all its future intervals and should not need to be
        restarted.  In short, a script that is created shouldn't need
        to restart more than once, and a script that is reloaded should
        restart only twice.

        """
        if self.db.time_format:
            # If the 'usual' time is set, use it
            seconds = self.ndb.usual
            if seconds is None:
                seconds, usual, details = get_next_wait(self.db.time_format)
                self.ndb.usual = usual

            if self.interval != seconds:
                self.restart(interval=seconds)

        if self.db.event_name and self.db.number is not None:
            obj = self.obj
            if not obj.callbacks:
                return

            event_name = self.db.event_name
            number = self.db.number
            obj.callbacks.call(event_name, obj, number=number)