Skip to content
This repository has been archived by the owner on Jul 4, 2020. It is now read-only.

Commit

Permalink
added some diagnostic errors when story initialization is done withou…
Browse files Browse the repository at this point in the history
…t proper driver startup first
  • Loading branch information
irmen committed Apr 13, 2018
1 parent d98cd8c commit caff6f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tale/base.py
Expand Up @@ -275,6 +275,10 @@ def __init__(self, name: str, title: str = None, *, descr: str = None, short_des
self.story_data = {} # type: Dict[Any, Any] # not used by Tale itself, story can put custom data here. Use builtin types only.
self.init()
if util.get_periodicals(self):
if mud_context.driver is None:
raise TaleError("Attempt to create MudObject while Driver hasn't been properly initialized yet. "
"Possible cause is importing zone or npc module files that create these objects "
"early before the driver itself loads them.")
mud_context.driver.register_periodicals(self)

def init(self) -> None:
Expand Down
4 changes: 4 additions & 0 deletions tale/driver.py
Expand Up @@ -719,6 +719,10 @@ def defer(self, due: DeferDueType, action: Callable, *vargs: Any, **kwargs: Any)
Triggering a deferred can not occur sooner than the server tick period!
"""
assert callable(action)
if self.game_clock is None:
raise errors.TaleError("Attempt to register a deferred action while Driver hasn't been properly started yet. "
"A possible cause is importing zone or npc module files that create MudObjects "
"that use @call_periodically, before the driver has been fully started and loads these by itself.")
if isinstance(due, datetime.datetime):
assert due >= self.game_clock.clock
deferred = Deferred(due, action, vargs, kwargs)
Expand Down

0 comments on commit caff6f9

Please sign in to comment.