Fixed bug in @batchcommand (Resolves Issue 287). Also updated @dig to again handle deleting ranges of dbrefs (with or without # in front).
This commit is contained in:
parent
86a44ab84d
commit
4dff822764
5 changed files with 14 additions and 12 deletions
|
|
@ -43,11 +43,11 @@
|
||||||
# everything in this block will be appended to the beginning of
|
# everything in this block will be appended to the beginning of
|
||||||
# all other #CODE blocks when they are executed.
|
# all other #CODE blocks when they are executed.
|
||||||
|
|
||||||
from ev import create, search
|
from ev import create_object, search_object
|
||||||
from game.gamesrc.objects.examples import red_button
|
from game.gamesrc.objects.examples import red_button
|
||||||
from game.gamesrc.objects import baseobjects
|
from ev import Object
|
||||||
|
|
||||||
limbo = search.objects('Limbo', global_search=True)[0]
|
limbo = search_object('Limbo')[0]
|
||||||
|
|
||||||
|
|
||||||
#CODE (create red button)
|
#CODE (create red button)
|
||||||
|
|
@ -59,7 +59,7 @@ limbo = search.objects('Limbo', global_search=True)[0]
|
||||||
# won't be able to be deleted in debug mode.
|
# won't be able to be deleted in debug mode.
|
||||||
|
|
||||||
# create a red button in limbo
|
# create a red button in limbo
|
||||||
red_button = create.create_object(red_button.RedButton, key="Red button",
|
red_button = create_object(red_button.RedButton, key="Red button",
|
||||||
location=limbo, aliases=["button"])
|
location=limbo, aliases=["button"])
|
||||||
|
|
||||||
# we take a look at what we created
|
# we take a look at what we created
|
||||||
|
|
@ -76,8 +76,8 @@ caller.msg("A %s was created." % red_button.key)
|
||||||
# the python variables we assign to must match the ones given in the
|
# the python variables we assign to must match the ones given in the
|
||||||
# header for the system to be able to delete them afterwards during a
|
# header for the system to be able to delete them afterwards during a
|
||||||
# debugging run.
|
# debugging run.
|
||||||
table = create.create_object(baseobjects.Object, key="Table", location=limbo)
|
table = create_object(Object, key="Table", location=limbo)
|
||||||
chair = create.create_object(baseobjects.Object, key="Chair", location=limbo)
|
chair = create_object(Object, key="Chair", location=limbo)
|
||||||
|
|
||||||
string = "A %s and %s were created. If debug was active, they were deleted again."
|
string = "A %s and %s were created. If debug was active, they were deleted again."
|
||||||
caller.msg(string % (table, chair))
|
caller.msg(string % (table, chair))
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ class CmdBatchCode(MuxCommand):
|
||||||
# un in-process (will block)
|
# un in-process (will block)
|
||||||
for inum in range(len(codes)):
|
for inum in range(len(codes)):
|
||||||
# loop through the batch file
|
# loop through the batch file
|
||||||
if not batch_cmd_exec(caller):
|
if not batch_code_exec(caller):
|
||||||
return
|
return
|
||||||
step_pointer(caller, 1)
|
step_pointer(caller, 1)
|
||||||
# clean out the safety cmdset and clean out all other temporary attrs.
|
# clean out the safety cmdset and clean out all other temporary attrs.
|
||||||
|
|
|
||||||
|
|
@ -545,7 +545,7 @@ class CmdDestroy(MuxCommand):
|
||||||
if not obj:
|
if not obj:
|
||||||
self.caller.msg(" (Objects to destroy must either be local or specified with a unique dbref.)")
|
self.caller.msg(" (Objects to destroy must either be local or specified with a unique dbref.)")
|
||||||
return ""
|
return ""
|
||||||
if not "override" in self.switches and obj.dbid == int(settings.CHARACTER_DEFAULT_HOME):
|
if not "override" in self.switches and obj.dbid == int(settings.CHARACTER_DEFAULT_HOME.lstrip("#")):
|
||||||
return "\nYou are trying to delete CHARACTER_DEFAULT_HOME. If you want to do this, use the /override switch."
|
return "\nYou are trying to delete CHARACTER_DEFAULT_HOME. If you want to do this, use the /override switch."
|
||||||
objname = obj.name
|
objname = obj.name
|
||||||
if not obj.access(caller, 'delete'):
|
if not obj.access(caller, 'delete'):
|
||||||
|
|
@ -572,10 +572,10 @@ class CmdDestroy(MuxCommand):
|
||||||
for objname in self.lhslist:
|
for objname in self.lhslist:
|
||||||
if '-' in objname:
|
if '-' in objname:
|
||||||
# might be a range of dbrefs
|
# might be a range of dbrefs
|
||||||
dmin, dmax = [utils.dbref(part) for part in objname.split('-', 1)]
|
dmin, dmax = [utils.dbref(part, reqhash=False) for part in objname.split('-', 1)]
|
||||||
if dmin and dmax:
|
if dmin and dmax:
|
||||||
for dbref in range(int(dmin),int(dmax+1)):
|
for dbref in range(int(dmin),int(dmax+1)):
|
||||||
string += delobj(str(dbref))
|
string += delobj("#" + str(dbref))
|
||||||
else:
|
else:
|
||||||
string += delobj(objname)
|
string += delobj(objname)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -801,7 +801,7 @@ class ObjectDB(TypedObject):
|
||||||
"""
|
"""
|
||||||
# Gather up everything that thinks this is its location.
|
# Gather up everything that thinks this is its location.
|
||||||
objs = ObjectDB.objects.filter(db_location=self)
|
objs = ObjectDB.objects.filter(db_location=self)
|
||||||
default_home_id = int(settings.CHARACTER_DEFAULT_HOME)
|
default_home_id = int(settings.CHARACTER_DEFAULT_HOME.lstrip("#"))
|
||||||
try:
|
try:
|
||||||
default_home = ObjectDB.objects.get(id=default_home_id)
|
default_home = ObjectDB.objects.get(id=default_home_id)
|
||||||
if default_home.dbid == _GA(self, "dbid"):
|
if default_home.dbid == _GA(self, "dbid"):
|
||||||
|
|
|
||||||
|
|
@ -284,12 +284,14 @@ def pypath_to_realpath(python_path, file_ending='.py'):
|
||||||
return "%s%s" % (path, file_ending)
|
return "%s%s" % (path, file_ending)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def dbref(dbref):
|
def dbref(dbref, reqhash=True):
|
||||||
"""
|
"""
|
||||||
Converts/checks if input is a valid dbref Valid forms of dbref
|
Converts/checks if input is a valid dbref Valid forms of dbref
|
||||||
(database reference number) are either a string '#N' or
|
(database reference number) are either a string '#N' or
|
||||||
an integer N. Output is the integer part.
|
an integer N. Output is the integer part.
|
||||||
"""
|
"""
|
||||||
|
if reqhash and not (isinstance(dbref, basestring) and dbref.startswith("#")):
|
||||||
|
return None
|
||||||
if isinstance(dbref, basestring):
|
if isinstance(dbref, basestring):
|
||||||
dbref = dbref.lstrip('#')
|
dbref = dbref.lstrip('#')
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue