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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue