mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 06:16:31 +01:00
Add custom error messages to search and have drop use them.
This commit is contained in:
parent
7fb35f4ef4
commit
7e7cd9211f
2 changed files with 11 additions and 10 deletions
|
|
@ -266,6 +266,7 @@ class CmdDrop(MuxCommand):
|
|||
|
||||
key = "drop"
|
||||
locks = "cmd:all()"
|
||||
arg_regex = r"\s|$"
|
||||
|
||||
def func(self):
|
||||
"Implement command"
|
||||
|
|
@ -277,13 +278,9 @@ class CmdDrop(MuxCommand):
|
|||
|
||||
# Because the DROP command by definition looks for items
|
||||
# in inventory, call the search function using location = caller
|
||||
results = caller.search(self.args, location=caller, quiet=True)
|
||||
|
||||
# now we send it into the error handler (this will output consistent
|
||||
# error messages if there are problems).
|
||||
obj = AT_SEARCH_RESULT(caller, self.args, results, False,
|
||||
nofound_string="You aren't carrying %s." % self.args,
|
||||
multimatch_string="You carry more than one %s:" % self.args)
|
||||
obj = caller.search(self.args, location=caller,
|
||||
nofound_string="You aren't carrying %s." % self.args,
|
||||
multimatch_string="You carry more than one %s:" % self.args)
|
||||
if not obj:
|
||||
return
|
||||
|
||||
|
|
@ -291,7 +288,7 @@ class CmdDrop(MuxCommand):
|
|||
caller.msg("You drop %s." % (obj.name,))
|
||||
caller.location.msg_contents("%s drops %s." %
|
||||
(caller.name, obj.name),
|
||||
exclude=caller)
|
||||
exclude=caller)
|
||||
# Call the object script's at_drop() method.
|
||||
obj.at_drop(caller)
|
||||
|
||||
|
|
|
|||
|
|
@ -317,7 +317,9 @@ class DefaultObject(ObjectDB):
|
|||
attribute_name=None,
|
||||
quiet=False,
|
||||
exact=False,
|
||||
candidates=None):
|
||||
candidates=None,
|
||||
nofound_string=None,
|
||||
multimatch_string=None):
|
||||
"""
|
||||
Returns the typeclass of an Object matching a search string/condition
|
||||
|
||||
|
|
@ -367,6 +369,8 @@ class DefaultObject(ObjectDB):
|
|||
is given. If not set, this list will automatically be defined
|
||||
to include the location, the contents of location and the
|
||||
caller's contents (inventory).
|
||||
nofound_string - optional custom string for not-found error message.
|
||||
multimatch_string - optional custom string for multimatch error header
|
||||
|
||||
Returns:
|
||||
quiet=False (default):
|
||||
|
|
@ -425,7 +429,7 @@ class DefaultObject(ObjectDB):
|
|||
exact=exact)
|
||||
if quiet:
|
||||
return results
|
||||
return _AT_SEARCH_RESULT(self, searchdata, results, global_search)
|
||||
return _AT_SEARCH_RESULT(self, searchdata, results, global_search, nofound_string, multimatch_string)
|
||||
|
||||
def search_player(self, searchdata, quiet=False):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue