diff --git a/evennia/contrib/tutorial_world/mob.py b/evennia/contrib/tutorial_world/mob.py index 2e331cb1f..acdb2f8be 100644 --- a/evennia/contrib/tutorial_world/mob.py +++ b/evennia/contrib/tutorial_world/mob.py @@ -181,13 +181,17 @@ class Mob(tut_objects.TutorialObject): """ idstring = "tutorial_mob" # this doesn't change 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. - 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_hook_key = hook_key if not stop: # 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): """ diff --git a/evennia/contrib/tutorial_world/rooms.py b/evennia/contrib/tutorial_world/rooms.py index 953dd5392..6a54b832e 100644 --- a/evennia/contrib/tutorial_world/rooms.py +++ b/evennia/contrib/tutorial_world/rooms.py @@ -310,7 +310,7 @@ class WeatherRoom(TutorialRoom): # "update_weather" on this object. The interval is randomized # so as to not have all weather rooms update at the same time. 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. self.db.tutorial_info = \ "This room has a Script running that has it echo a weather-related message at irregular intervals." diff --git a/evennia/scripts/tickerhandler.py b/evennia/scripts/tickerhandler.py index 2ad2205b2..c078660c4 100644 --- a/evennia/scripts/tickerhandler.py +++ b/evennia/scripts/tickerhandler.py @@ -435,6 +435,10 @@ class TickerHandler(object): 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) store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent) self.ticker_storage[store_key] = (args, kwargs) @@ -455,6 +459,10 @@ class TickerHandler(object): 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) store_key = self._store_key(obj, path, interval, callfunc, idstring, persistent) to_remove = self.ticker_storage.pop(store_key, None)