diff --git a/CHANGELOG.md b/CHANGELOG.md index 670de30345..dcafd63b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,8 @@ Up requirements to Django 3.2+ accepting `*args`, as `settings.EXTRA_LAUNCHER_COMMANDS = {'mycmd': 'path.to.callable', ...}`. - New `XYZGrid` contrib, adding x,y,z grid coordinates with in-game map and pathfinding. Controlled outside of the game via custom evennia launcher command. +- `Script.delete` has new kwarg `stop_task=True`, that can be used to avoid + infinite recursion when wanting to set up Script to delete-on-stop. ### Evennia 0.9.5 (2019-2020) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index 8e643ce477..f2fcc12c95 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -436,12 +436,20 @@ class ScriptBase(ScriptDB, metaclass=TypeclassBase): # autostart the script self._start_task(force_restart=True) - def delete(self): + def delete(self, stop_task=True): """ - Delete the Script. Makes sure to stop any timer tasks first. + Delete the Script. Normally stops any timer task. This fires at_script_delete before + deletion. + + Args: + stop_task (bool, optional): If unset, the task will not be stopped + when this method is called. The main reason for setting this to False + is if wanting to delete the script from the at_stop method - setting + this will then avoid an infinite recursion. """ - self._stop_task() + if stop_task: + self._stop_task() self.at_script_delete() super().delete()