Remove prototypes._RE_DBREF and add new dbref() to protfuncs
This commit is contained in:
parent
f6d62e2f69
commit
979d24a12f
3 changed files with 14 additions and 39 deletions
|
|
@ -37,6 +37,7 @@ prototype key (this value must be possible to serialize in an Attribute).
|
|||
|
||||
from ast import literal_eval
|
||||
from random import randint as base_randint, random as base_random, choice as base_choice
|
||||
import re
|
||||
|
||||
from evennia.utils import search
|
||||
from evennia.utils.utils import justify as base_justify, is_iter, to_str
|
||||
|
|
@ -325,3 +326,15 @@ def objlist(*args, **kwargs):
|
|||
|
||||
"""
|
||||
return ["#{}".format(obj.id) for obj in _obj_search(return_list=True, *args, **kwargs)]
|
||||
|
||||
|
||||
def dbref(*args, **kwargs):
|
||||
"""
|
||||
Usage $dbref(<#dbref>)
|
||||
Returns one Object searched globally by #dbref. Error if #dbref is invalid.
|
||||
"""
|
||||
_RE_DBREF = re.compile(r"\#[0-9]+")
|
||||
if not args or len(args) < 1 or _RE_DBREF.match(args[0]) is None:
|
||||
raise ValueError('$dbref requires a valid #dbref argument.')
|
||||
|
||||
return obj(args[0])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue