Make Sripthandler.add not fail if passed instantiated script. Resolve #3272

This commit is contained in:
Griatch 2023-09-23 22:45:11 +02:00
parent cf38de0922
commit 808bde0c7c
2 changed files with 10 additions and 3 deletions

View file

@ -7,12 +7,15 @@
instead of 'Custom' (InspectorCaracal)
- [Fix][pull3274]: Traceback when creating objects with initial nattributes
(InspectorCaracal)
- [Fix][issue3272]: Make sure `ScriptHandler.add` does not fail if passed an
instantiated script.
- Docs: Typo fixes and starting earlier with explaining how to add to the
default cmdsets.
[pull3267]: https://github.com/evennia/evennia/pull/3267
[pull3270]: https://github.com/evennia/evennia/pull/3270
[pull3274]: https://github.com/evennia/evennia/pull/3274
[issue3272]: https://github.com/evennia/evennia/issues/3272
## Evennia 2.3.0

View file

@ -76,10 +76,14 @@ class ScriptHandler(object):
script = create.create_script(
scriptclass, key=key, account=self.obj, autostart=autostart
)
else:
# adding to an Object. We wait to autostart so we can differentiate
# a failing creation from a script that immediately starts/stops.
elif isinstance(scriptclass, str) or callable(scriptclass):
# a str or class to use create before adding to an Object. We wait to autostart
# so we can differentiate a failing creation from a script that immediately starts/stops.
script = create.create_script(scriptclass, key=key, obj=self.obj, autostart=False)
else:
# already an instantiated class
script = scriptclass
if not script:
logger.log_err(f"Script {scriptclass} failed to be created.")
return None