mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Add key:typeclass support for scripts command
This commit is contained in:
parent
bb751ad2ff
commit
310a895bb5
4 changed files with 42 additions and 18 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## Main branch
|
||||
|
||||
Feat: Support `scripts key:typeclass` form to create global scripts
|
||||
with dynamic keys (rather than just relying on typeclass' key). Support
|
||||
searching using the same syntax (Griatch)
|
||||
[Fix][issue3556]: Better error if trying to treat ObjectDB as a typeclass (Griatch)
|
||||
[Fix][issue3590]: Make `examine` command properly show `strattr` type
|
||||
Attribute values (Griatch)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,25 @@
|
|||
# Changelog
|
||||
|
||||
## Main branch
|
||||
|
||||
Feat: Support `scripts key:typeclass` form to create global scripts
|
||||
with dynamic keys (rather than just relying on typeclass' key). Support
|
||||
searching using the same syntax (Griatch)
|
||||
[Fix][issue3556]: Better error if trying to treat ObjectDB as a typeclass (Griatch)
|
||||
[Fix][issue3590]: Make `examine` command properly show `strattr` type
|
||||
Attribute values (Griatch)
|
||||
[Fix][issue3519]: `GLOBAL_SCRIPTS` container didn't list global scripts not
|
||||
defined explicitly to be restarted/recrated in settings.py (Griatch)
|
||||
Fix: Passing an already instantiated Script to `obj.scripts.add` (`ScriptHandler.add`)
|
||||
did not add it to the handler's object (Griatch)
|
||||
[Docs][issue3591]: Fix of NPC reaction tutorial code (Griatch)
|
||||
|
||||
[issue3591]: https://github.com/evennia/evennia/issues/3591
|
||||
[issue3590]: https://github.com/evennia/evennia/issues/3590
|
||||
[issue3556]: https://github.com/evennia/evennia/issues/3556
|
||||
[issue3519]: https://github.com/evennia/evennia/issues/3519
|
||||
|
||||
|
||||
## Evennia 4.3.0
|
||||
|
||||
Aug 11, 2024
|
||||
|
|
|
|||
|
|
@ -3521,16 +3521,22 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
hide_script_paths = ("evennia.prototypes.prototypes.DbPrototype",)
|
||||
|
||||
def _search_script(self):
|
||||
# test first if this is a script match
|
||||
print("search:", self.key_query, self.typeclass_query)
|
||||
if self.key_query:
|
||||
scripts = ScriptDB.objects.filter(
|
||||
db_key__iexact=self.key_query, db_typeclass_path__iendswith=self.typeclass_query
|
||||
).exclude(db_typeclass_path__in=self.hide_script_paths)
|
||||
|
||||
# see if a dbref was provided
|
||||
if dbref(self.typeclass_query):
|
||||
scripts = ScriptDB.objects.get_all_scripts(self.typeclass_query)
|
||||
if scripts:
|
||||
return scripts
|
||||
self.caller.msg(f"No script found with dbref {self.typeclass_query}")
|
||||
raise InterruptCommand
|
||||
|
||||
# try typeclass path
|
||||
# if we provided a key, we must find an exact match, otherwise we're creating that anew
|
||||
if self.key_query:
|
||||
return ScriptDB.objects.filter(
|
||||
db_key__iexact=self.key_query, db_typeclass_path__iendswith=self.typeclass_query
|
||||
).exclude(db_typeclass_path__in=self.hide_script_paths)
|
||||
|
||||
# the more general case - try typeclass path
|
||||
scripts = (
|
||||
ScriptDB.objects.filter(db_typeclass_path__iendswith=self.typeclass_query)
|
||||
.exclude(db_typeclass_path__in=self.hide_script_paths)
|
||||
|
|
@ -3539,11 +3545,6 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
|
|||
if scripts:
|
||||
return scripts
|
||||
|
||||
# try dbref
|
||||
scripts = ScriptDB.objects.get_all_scripts(self.typeclass_query)
|
||||
if scripts:
|
||||
return scripts
|
||||
|
||||
args = self.typeclass_query
|
||||
if "-" in args:
|
||||
# may be a dbref-range
|
||||
|
|
|
|||
|
|
@ -1653,17 +1653,17 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
)
|
||||
|
||||
def test_script_multi_delete(self):
|
||||
script1 = create.create_script()
|
||||
script2 = create.create_script()
|
||||
script3 = create.create_script()
|
||||
script1 = create.create_script(key="script1")
|
||||
script2 = create.create_script(key="script2")
|
||||
script3 = create.create_script(key="script3")
|
||||
|
||||
self.call(
|
||||
building.CmdScripts(),
|
||||
"/delete #{}-#{}".format(script1.id, script3.id),
|
||||
(
|
||||
f"Global Script Deleted - #{script1.id} (evennia.scripts.scripts.DefaultScript)|"
|
||||
f"Global Script Deleted - #{script2.id} (evennia.scripts.scripts.DefaultScript)|"
|
||||
f"Global Script Deleted - #{script3.id} (evennia.scripts.scripts.DefaultScript)"
|
||||
f"Global Script Deleted - script1 (evennia.scripts.scripts.DefaultScript)|"
|
||||
f"Global Script Deleted - script2 (evennia.scripts.scripts.DefaultScript)|"
|
||||
f"Global Script Deleted - script3 (evennia.scripts.scripts.DefaultScript)"
|
||||
),
|
||||
inputs=["y"],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue