Added the holds() lock function to check for an name or id held in inventory.

This commit is contained in:
Griatch 2011-03-20 10:22:21 +00:00
parent a429047452
commit 857b253a6f
2 changed files with 30 additions and 12 deletions

View file

@ -291,6 +291,21 @@ def attr_ne(accessing_obj, accessed_obj, *args, **kwargs):
"""
return attr(accessing_obj, accessed_obj, *args, **{'compare':'ne'})
def holds(accessing_obj, accessed_obj, objid, *args, **kwargs):
"""
Usage:
holds(object_id)
This is passed if accessing_obj 'contains' an object with the given
key name or dbref.
"""
dbref = utils.dbref(objid)
contains = accessing_obj.contains
if dbref and any((True for obj in contains if obj.id == dbref)):
return True
objid = objid.lower()
return any((True for obj in contains if obj.name.lower() == objid))
def superuser(*args, **kwargs):
"""
Only accepts an accesing_obj that is superuser (e.g. user #1)