You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.6 KiB
47 lines
1.6 KiB
"""
|
|
|
|
Lockfuncs
|
|
|
|
Lock functions are functions available when defining lock strings,
|
|
which in turn limits access to various game systems.
|
|
|
|
All functions defined globally in this module are assumed to be
|
|
available for use in lockstrings to determine access. See the
|
|
Evennia documentation for more info on locks.
|
|
|
|
A lock function is always called with two arguments, accessing_obj and
|
|
accessed_obj, followed by any number of arguments. All possible
|
|
arguments should be handled with *args, **kwargs. The lock function
|
|
should handle all eventual tracebacks by logging the error and
|
|
returning False.
|
|
|
|
Lock functions in this module extend (and will overload same-named)
|
|
lock functions from evennia.locks.lockfuncs.
|
|
|
|
"""
|
|
|
|
# def myfalse(accessing_obj, accessed_obj, *args, **kwargs):
|
|
# """
|
|
# called in lockstring with myfalse().
|
|
# A simple logger that always returns false. Prints to stdout
|
|
# for simplicity, should use utils.logger for real operation.
|
|
# """
|
|
# print "%s tried to access %s. Access denied." % (accessing_obj, accessed_obj)
|
|
# return False
|
|
|
|
def cmdinside(accessing_obj, accessed_obj, *args, **kwargs):
|
|
'''
|
|
Usage: cmdinside()
|
|
|
|
Used to lock commands and only allows access if the command
|
|
is defined on an object which accessing_obj is inside of.
|
|
'''
|
|
return accessed_obj.obj == accessing_obj.location
|
|
|
|
def is_a(accessing_obj, accessed_obj, expected_type=None):
|
|
'''
|
|
Usage: is_a(typename='Example')
|
|
|
|
Used to determine if a certain object matches expected object
|
|
'''
|
|
return type(accessing_obj) == expected_type or accessing_obj.typename == expected_type
|
|
|