Migrate. Added the "view" access restriction (to make objects invisible). Also changed the input of ObjectDB.objects.object_search() to not require a caller as an argument (this makes it consistent with other search methods). All default systems should have updated to the new call, but if you have custom calls, you need to change them to fit the new syntax (this is only important if explicitly use ObjectDB.objects.object_search; if you just use caller.search you should be fine)
This commit is contained in:
parent
28fe2ad3f4
commit
27809694d7
13 changed files with 267 additions and 34 deletions
|
|
@ -226,9 +226,9 @@ def pid(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
def attr(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
Usage:
|
||||
has_attr(attrname)
|
||||
has_attr(attrname, value)
|
||||
has_attr(attrname, value, compare=type)
|
||||
attr(attrname)
|
||||
attr(attrname, value)
|
||||
attr(attrname, value, compare=type)
|
||||
|
||||
where compare's type is one of (eq,gt,lt,ge,le,ne) and signifies
|
||||
how the value should be compared with one on accessing_obj (so
|
||||
|
|
@ -288,6 +288,37 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs):
|
|||
return True
|
||||
return False
|
||||
|
||||
def objattr(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
Usage:
|
||||
objattr(attrname)
|
||||
objattr(attrname, value)
|
||||
objattr(attrname, value, compare=type)
|
||||
|
||||
Works like attr, except it looks for an attribute on
|
||||
accessing_obj.obj, if such an entity exists. Suitable
|
||||
for commands.
|
||||
|
||||
"""
|
||||
if hasattr(accessing_obj, "obj"):
|
||||
return attr(accessing_obj.obj, accessed_obj, *args, **kwargs)
|
||||
|
||||
def locattr(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
Usage:
|
||||
locattr(attrname)
|
||||
locattr(attrname, value)
|
||||
locattr(attrname, value, compare=type)
|
||||
|
||||
Works like attr, except it looks for an attribute on
|
||||
accessing_obj.location, if such an entity exists. Suitable
|
||||
for commands.
|
||||
|
||||
"""
|
||||
if hasattr(accessing_obj, "location"):
|
||||
return attr(accessing_obj.location, accessed_obj, *args, **kwargs)
|
||||
|
||||
|
||||
def attr_eq(accessing_obj, accessed_obj, *args, **kwargs):
|
||||
"""
|
||||
Usage:
|
||||
|
|
@ -351,6 +382,28 @@ def holds(accessing_obj, accessed_obj, objid, *args, **kwargs):
|
|||
objid = objid.lower()
|
||||
return any((True for obj in contains if obj.name.lower() == objid))
|
||||
|
||||
def carried(accessing_obj, accessed_obj):
|
||||
"""
|
||||
Usage:
|
||||
carried()
|
||||
|
||||
This is passed if accessed_obj is carried by accessing_obj (that is,
|
||||
accessed_obj.location == accessing_obj)
|
||||
"""
|
||||
return hasattr(accessed_obj, "location") and accessed_obj.location == accessing_obj
|
||||
|
||||
def objcarried(accessing_obj, accessed_obj):
|
||||
"""
|
||||
Usage:
|
||||
objcarried()
|
||||
|
||||
Like carried, except this lock looks for a property "obj" on the accessed_obj
|
||||
and tries to determing if *this* is carried by accessing_obj. This works well
|
||||
for commands and scripts.
|
||||
"""
|
||||
return hasattr(accessed_obj, "obj") and accessed_obj.obj and \
|
||||
hasattr(accessed_obj.obj, "location") and accessed_obj.obj.location == accessing_obj
|
||||
|
||||
def superuser(*args, **kwargs):
|
||||
"""
|
||||
Only accepts an accesing_obj that is superuser (e.g. user #1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue