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:
Griatch 2012-09-21 08:36:59 +02:00
parent 8ad58a3e19
commit e874343387
2 changed files with 10 additions and 5 deletions

View file

@ -275,7 +275,7 @@ class CmdGet(MuxCommand):
if not self.args:
caller.msg("Get what?")
return
obj = caller.search(self.args)
obj = caller.search(self.args, location=caller.location)
if not obj:
return
if caller == obj:
@ -326,7 +326,7 @@ 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, ignore_errors=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)

View file

@ -514,7 +514,8 @@ class ObjectDB(TypedObject):
location/inventory. This is overruled if location keyword is given.
attribute_name: (string) Which attribute to match (if None, uses default 'name')
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
ignore_errors : Don't display any error messages even
if there are none/multiple matches -
@ -562,10 +563,14 @@ class ObjectDB(TypedObject):
if global_search:
# only allow exact matching if searching the entire database
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:
# local search. Candidates are self.contents, self.location and self.location.contents
if not location:
location = self.location
location = self.location
candidates = self.contents
if location:
candidates = candidates + [location] + location.contents