Fixed various Script issues. Resolves #2010. Might affect #2006.

This commit is contained in:
Griatch 2020-01-18 20:50:26 +01:00
parent a9b4d8e826
commit 7f7dd3bbf2
5 changed files with 19 additions and 12 deletions

View file

@ -308,7 +308,7 @@ class CmdPy(COMMAND_DEFAULT_CLASS):
clientraw - turn off all client-specific escaping. Note that this may
lead to different output depending on prototocol (such as angular brackets
being parsed as HTML in the webclient but not in telnet clients)
noecho - in Python console mode, turn off the input echo (e.g. if your client
noecho - in Python console mode, turn off the input echo (e.g. if your client
does this for you already)
Without argument, open a Python console in-game. This is a full console,
@ -429,13 +429,14 @@ def format_script_list(scripts):
nextrep = script.time_until_next_repeat()
if nextrep is None:
nextrep = "PAUS" if script.db._paused_time else "--"
nextrep = "PAUSED" if script.db._paused_time else "--"
else:
nextrep = "%ss" % nextrep
maxrepeat = script.repeats
remaining = script.remaining_repeats() or 0
if maxrepeat:
rept = "%i/%i" % (maxrepeat - script.remaining_repeats(), maxrepeat)
rept = "%i/%i" % (maxrepeat - remaining, maxrepeat)
else:
rept = "-/-"

View file

@ -298,6 +298,9 @@ class GametimeScript(DefaultScript):
def at_repeat(self):
"""Call the callback and reset interval."""
from evennia.utils.utils import calledby
callback = self.db.callback
if callback:
callback()

View file

@ -69,7 +69,7 @@ class ExtendedLoopingCall(LoopingCall):
steps if we want.
"""
assert not self.running, "Tried to start an already running " "ExtendedLoopingCall."
assert not self.running, "Tried to start an already running ExtendedLoopingCall."
if interval < 0:
raise ValueError("interval must be >= 0")
self.running = True
@ -107,7 +107,8 @@ class ExtendedLoopingCall(LoopingCall):
if self.start_delay:
self.start_delay = None
self.starttime = self.clock.seconds()
LoopingCall.__call__(self)
if self._deferred:
LoopingCall.__call__(self)
def force_repeat(self):
"""
@ -118,7 +119,7 @@ class ExtendedLoopingCall(LoopingCall):
running.
"""
assert self.running, "Tried to fire an ExtendedLoopingCall " "that was not running."
assert self.running, "Tried to fire an ExtendedLoopingCall that was not running."
self.call.cancel()
self.call = None
self.starttime = self.clock.seconds()
@ -173,7 +174,8 @@ class ScriptBase(ScriptDB, metaclass=TypeclassBase):
)
del self.db._paused_time
del self.db._paused_repeats
else:
elif not self.ndb._task.running:
# starting script anew
self.ndb._task.start(self.db_interval, now=not self.db_start_delay)
@ -185,6 +187,7 @@ class ScriptBase(ScriptDB, metaclass=TypeclassBase):
task = self.ndb._task
if task and task.running:
task.stop()
self.ndb._task = None
def _step_errback(self, e):
"""
@ -266,13 +269,13 @@ class ScriptBase(ScriptDB, metaclass=TypeclassBase):
self.db_key = cdict["key"]
updates.append("db_key")
if cdict.get("interval") and self.interval != cdict["interval"]:
self.db_interval = cdict["interval"]
self.db_interval = max(0, cdict["interval"])
updates.append("db_interval")
if cdict.get("start_delay") and self.start_delay != cdict["start_delay"]:
self.db_start_delay = cdict["start_delay"]
updates.append("db_start_delay")
if cdict.get("repeats") and self.repeats != cdict["repeats"]:
self.db_repeats = cdict["repeats"]
self.db_repeats = max(0, cdict["repeats"])
updates.append("db_repeats")
if cdict.get("persistent") and self.persistent != cdict["persistent"]:
self.db_persistent = cdict["persistent"]

View file

@ -416,7 +416,7 @@ class Evennia(object):
yield [
(s.pause(manual_pause=False), s.at_server_reload())
for s in ScriptDB.get_all_cached_instances()
if s.is_active or s.attributes.has("_manual_pause")
if s.id and (s.is_active or s.attributes.has("_manual_pause"))
]
yield self.sessions.all_sessions_portal_sync()
self.at_server_reload_stop()

View file

@ -255,11 +255,11 @@ def create_script(
if obj:
kwarg["db_obj"] = dbid_to_obj(obj, _ObjectDB)
if interval:
kwarg["db_interval"] = interval
kwarg["db_interval"] = max(0, interval)
if start_delay:
kwarg["db_start_delay"] = start_delay
if repeats:
kwarg["db_repeats"] = repeats
kwarg["db_repeats"] = max(0, repeats)
if persistent:
kwarg["db_persistent"] = persistent
if desc: