Cleaned up @link, @open and @dig, making these commands more useful and less buggy with strange input. Also made them work not only with #dbrefs but with any unique game object (possibly one should limit this to e.g. room's); if there's a multiple match a list of the relevant dbrefs are shown. You can also now inspect links/home settins using this command.

@open also supports script_parents when creating exits.
/Griatch
This commit is contained in:
Griatch 2009-10-05 23:06:57 +00:00
parent 66095a0b16
commit 42254355a0
3 changed files with 201 additions and 105 deletions

View file

@ -133,15 +133,20 @@ class ObjectManager(models.Manager):
except IndexError:
return None
def global_object_name_search(self, ostring, exact_match=False):
def global_object_name_search(self, ostring, exact_match=False, limit_types=[]):
"""
Searches through all objects for a name match.
limit_types is a list of types as defined in defines_global.
"""
if self.is_dbref(ostring):
return [self.dbref_search(ostring, limit_types=limit_types)]
if exact_match:
o_query = self.filter(name__iexact=ostring)
else:
o_query = self.filter(name__icontains=ostring)
if limit_types:
o_query = o_query.include(type__in=limit_types)
return o_query.exclude(type__in=[defines_global.OTYPE_GARBAGE,
defines_global.OTYPE_GOING])

View file

@ -2,6 +2,7 @@
This is where all of the crucial, core object models reside.
"""
import re
import traceback
try: import cPickle as pickle
except ImportError: import pickle
@ -603,12 +604,16 @@ class Object(models.Model):
attrib: (str) The attribute's name.
"""
if self.has_attribute(attrib):
attrib = Attribute.objects.filter(attr_object=self).filter(attr_name=attrib)[0]
try:
attrib = Attribute.objects.filter(attr_object=self).filter(attr_name=attrib)[0]
except:
# safety, if something goes wrong (like unsynced db), catch it.
logger.log_errmsg(traceback.print_exc())
return default
return attrib.get_value()
else:
return default
def get_attribute_obj(self, attrib):
"""
Returns the attribute object matching the specified name.