Adjusted search() functionality to handle also a list of location(s) to search. Changed "get" command to not search inventory (which could lead to multimatch errors).
This commit is contained in:
parent
8ad58a3e19
commit
e874343387
2 changed files with 10 additions and 5 deletions
|
|
@ -275,7 +275,7 @@ class CmdGet(MuxCommand):
|
||||||
if not self.args:
|
if not self.args:
|
||||||
caller.msg("Get what?")
|
caller.msg("Get what?")
|
||||||
return
|
return
|
||||||
obj = caller.search(self.args)
|
obj = caller.search(self.args, location=caller.location)
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
if caller == obj:
|
if caller == obj:
|
||||||
|
|
@ -326,7 +326,7 @@ class CmdDrop(MuxCommand):
|
||||||
# Because the DROP command by definition looks for items
|
# Because the DROP command by definition looks for items
|
||||||
# in inventory, call the search function using location = caller
|
# in inventory, call the search function using location = caller
|
||||||
results = caller.search(self.args, location=caller, ignore_errors=True)
|
results = caller.search(self.args, location=caller, ignore_errors=True)
|
||||||
|
|
||||||
# now we send it into the error handler (this will output consistent
|
# now we send it into the error handler (this will output consistent
|
||||||
# error messages if there are problems).
|
# error messages if there are problems).
|
||||||
obj = AT_SEARCH_RESULT(caller, self.args, results, False)
|
obj = AT_SEARCH_RESULT(caller, self.args, results, False)
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,8 @@ class ObjectDB(TypedObject):
|
||||||
location/inventory. This is overruled if location keyword is given.
|
location/inventory. This is overruled if location keyword is given.
|
||||||
attribute_name: (string) Which attribute to match (if None, uses default 'name')
|
attribute_name: (string) Which attribute to match (if None, uses default 'name')
|
||||||
use_nicks : Use nickname replace (off by default)
|
use_nicks : Use nickname replace (off by default)
|
||||||
location : If None, use caller's current location
|
location : If None, use caller's current location, and caller.contents.
|
||||||
|
This can also be a list of locations
|
||||||
player: return the Objects' controlling Player, instead, if available
|
player: return the Objects' controlling Player, instead, if available
|
||||||
ignore_errors : Don't display any error messages even
|
ignore_errors : Don't display any error messages even
|
||||||
if there are none/multiple matches -
|
if there are none/multiple matches -
|
||||||
|
|
@ -562,10 +563,14 @@ class ObjectDB(TypedObject):
|
||||||
if global_search:
|
if global_search:
|
||||||
# only allow exact matching if searching the entire database
|
# only allow exact matching if searching the entire database
|
||||||
exact = True
|
exact = True
|
||||||
|
elif location:
|
||||||
|
# location(s) were given
|
||||||
|
candidates = []
|
||||||
|
for obj in make_iter(location):
|
||||||
|
candidates.extend([o.dbobj for o in obj.contents])
|
||||||
else:
|
else:
|
||||||
# local search. Candidates are self.contents, self.location and self.location.contents
|
# local search. Candidates are self.contents, self.location and self.location.contents
|
||||||
if not location:
|
location = self.location
|
||||||
location = self.location
|
|
||||||
candidates = self.contents
|
candidates = self.contents
|
||||||
if location:
|
if location:
|
||||||
candidates = candidates + [location] + location.contents
|
candidates = candidates + [location] + location.contents
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue