This commit is contained in:
Oscuro87 2020-01-28 15:48:16 +01:00
parent a43fef23e5
commit cff07bd8d5

View file

@ -139,6 +139,9 @@ class ExtendedLoopingCall(LoopingCall):
if self.running: if self.running:
total_runtime = self.clock.seconds() - self.starttime total_runtime = self.clock.seconds() - self.starttime
interval = self.start_delay or self.interval interval = self.start_delay or self.interval
# Fairly naive ZeroDivision error bug workaround, see ticket: https://github.com/evennia/evennia/issues/2039#issue-555828740
if self.interval == 0:
self.interval = 1
return interval - (total_runtime % self.interval) return interval - (total_runtime % self.interval)
return None return None
@ -564,10 +567,7 @@ class DefaultScript(ScriptBase):
Restarts an already existing/running Script from the Restarts an already existing/running Script from the
beginning, optionally using different settings. This will beginning, optionally using different settings. This will
first call the stop hooks, and then the start hooks again. first call the stop hooks, and then the start hooks again.
it should not accept 0 at alln seconds. if `None`, will use the
Args:
interval (int, optional): Allows for changing the interval
of the Script. Given in seconds. if `None`, will use the
already stored interval. already stored interval.
repeats (int, optional): The number of repeats. If unset, will repeats (int, optional): The number of repeats. If unset, will
use the previous setting. use the previous setting.
@ -586,7 +586,8 @@ class DefaultScript(ScriptBase):
del self.db._manual_pause del self.db._manual_pause
del self.db._paused_callcount del self.db._paused_callcount
# set new flags and start over # set new flags and start over
if interval is not None: # Avoid intervals lower than zero
if interval is not None and interval >= 0:
self.interval = interval self.interval = interval
if repeats is not None: if repeats is not None:
self.repeats = repeats self.repeats = repeats