Fixed old calls to tickerhandler from the tutorial_world. Also added a better error when this happens. This resolves #952.
This commit is contained in:
parent
910d539d45
commit
cce87a8399
3 changed files with 16 additions and 4 deletions
|
|
@ -181,13 +181,17 @@ class Mob(tut_objects.TutorialObject):
|
||||||
"""
|
"""
|
||||||
idstring = "tutorial_mob" # this doesn't change
|
idstring = "tutorial_mob" # this doesn't change
|
||||||
last_interval = self.db.last_ticker_interval
|
last_interval = self.db.last_ticker_interval
|
||||||
if last_interval:
|
last_hook_key = self.db.last_hook_key
|
||||||
|
if last_interval and last_hook_key:
|
||||||
# we have a previous subscription, kill this first.
|
# we have a previous subscription, kill this first.
|
||||||
TICKER_HANDLER.remove(self, last_interval, idstring)
|
TICKER_HANDLER.remove(interval=last_interval,
|
||||||
|
callback=getattr(self, last_hook_key), idstring=idstring)
|
||||||
self.db.last_ticker_interval = interval
|
self.db.last_ticker_interval = interval
|
||||||
|
self.db.last_hook_key = hook_key
|
||||||
if not stop:
|
if not stop:
|
||||||
# set the new ticker
|
# set the new ticker
|
||||||
TICKER_HANDLER.add(self, interval, idstring, hook_key)
|
TICKER_HANDLER.add(interval=interval,
|
||||||
|
callback=getattr(self, hook_key), idstring=idstring)
|
||||||
|
|
||||||
def _find_target(self, location):
|
def _find_target(self, location):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ class WeatherRoom(TutorialRoom):
|
||||||
# "update_weather" on this object. The interval is randomized
|
# "update_weather" on this object. The interval is randomized
|
||||||
# so as to not have all weather rooms update at the same time.
|
# so as to not have all weather rooms update at the same time.
|
||||||
interval = random.randint(50, 70)
|
interval = random.randint(50, 70)
|
||||||
TICKER_HANDLER.add(self, interval, idstring="tutorial", hook_key="update_weather")
|
TICKER_HANDLER.add(interval=interval, callback=self.update_weather, idstring="tutorial")
|
||||||
# this is parsed by the 'tutorial' command on TutorialRooms.
|
# this is parsed by the 'tutorial' command on TutorialRooms.
|
||||||
self.db.tutorial_info = \
|
self.db.tutorial_info = \
|
||||||
"This room has a Script running that has it echo a weather-related message at irregular intervals."
|
"This room has a Script running that has it echo a weather-related message at irregular intervals."
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,10 @@ class TickerHandler(object):
|
||||||
when wanting to modify/remove the ticker later.
|
when wanting to modify/remove the ticker later.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if isinstance(callback, int):
|
||||||
|
raise RuntimeError("TICKER_HANDLER.add has changed: "
|
||||||
|
"the interval is now the first argument, callback the second.")
|
||||||
|
|
||||||
obj, path, callfunc = self._get_callback(callback)
|
obj, path, callfunc = self._get_callback(callback)
|
||||||
store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent)
|
store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent)
|
||||||
self.ticker_storage[store_key] = (args, kwargs)
|
self.ticker_storage[store_key] = (args, kwargs)
|
||||||
|
|
@ -455,6 +459,10 @@ class TickerHandler(object):
|
||||||
idstring (str, optional): Identifier id of ticker to remove.
|
idstring (str, optional): Identifier id of ticker to remove.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if isinstance(callback, int):
|
||||||
|
raise RuntimeError("TICKER_HANDLER.remove has changed: "
|
||||||
|
"the interval is now the first argument, callback the second.")
|
||||||
|
|
||||||
obj, path, callfunc = self._get_callback(callback)
|
obj, path, callfunc = self._get_callback(callback)
|
||||||
store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent)
|
store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent)
|
||||||
to_remove = self.ticker_storage.pop(store_key, None)
|
to_remove = self.ticker_storage.pop(store_key, None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue