mirror of
https://github.com/evennia/evennia.git
synced 2026-04-04 15:07:16 +02:00
Resolves issue 133. Added the location keyword to the ObjectDB.search() method for easier customizable object searches.
This commit is contained in:
parent
2bdaf034c8
commit
9dcfea5971
3 changed files with 20 additions and 15 deletions
|
|
@ -167,7 +167,7 @@ class ObjectManager(TypedObjectManager):
|
|||
@returns_typeclass_list
|
||||
def object_search(self, character, ostring,
|
||||
global_search=False,
|
||||
attribute_name=None):
|
||||
attribute_name=None, location=None):
|
||||
"""
|
||||
Search as an object and return results.
|
||||
|
||||
|
|
@ -177,13 +177,15 @@ class ObjectManager(TypedObjectManager):
|
|||
global_search: Search all objects, not just the current location/inventory
|
||||
attribute_name: (string) Which attribute to search in each object.
|
||||
If None, the default 'key' attribute is used.
|
||||
location: If None, character.location will be used.
|
||||
"""
|
||||
#ostring = str(ostring).strip()
|
||||
|
||||
if not ostring or not character:
|
||||
return None
|
||||
|
||||
location = character.location
|
||||
if not location:
|
||||
location = character.location
|
||||
|
||||
# Easiest case - dbref matching (always exact)
|
||||
dbref = self.dbref(ostring)
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ class ObjectDB(TypedObject):
|
|||
def search(self, ostring,
|
||||
global_search=False,
|
||||
attribute_name=None,
|
||||
use_nicks=False,
|
||||
use_nicks=False, location=None,
|
||||
ignore_errors=False):
|
||||
"""
|
||||
Perform a standard object search in the database, handling
|
||||
|
|
@ -451,6 +451,7 @@ class ObjectDB(TypedObject):
|
|||
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
|
||||
ignore_errors : Don't display any error messages even
|
||||
if there are none/multiple matches -
|
||||
just return the result as a list.
|
||||
|
|
@ -473,7 +474,8 @@ class ObjectDB(TypedObject):
|
|||
|
||||
results = ObjectDB.objects.object_search(self, ostring,
|
||||
global_search=global_search,
|
||||
attribute_name=attribute_name)
|
||||
attribute_name=attribute_name,
|
||||
location=location)
|
||||
|
||||
if ignore_errors:
|
||||
return results
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue