diff --git a/game/gamesrc/world/examples/batch_code.py b/game/gamesrc/world/examples/batch_code.py index 1998b524fc..79c65248e6 100644 --- a/game/gamesrc/world/examples/batch_code.py +++ b/game/gamesrc/world/examples/batch_code.py @@ -43,7 +43,7 @@ from src.utils import create, search from game.gamesrc.objects.examples import red_button from game.gamesrc.objects import baseobjects -limbo = search.objects(caller, 'Limbo', global_search=True)[0] +limbo = search.objects('Limbo', global_search=True)[0] #CODE (create red button) diff --git a/src/commands/default/batchprocess.py b/src/commands/default/batchprocess.py index e049a966be..9577f030b1 100644 --- a/src/commands/default/batchprocess.py +++ b/src/commands/default/batchprocess.py @@ -151,7 +151,7 @@ def show_curr(caller, showall=False): string += "{G(hh for help)" if showall: for line in codeall.split('\n'): - string += "\n{n>>> %s" % line + string += "\n{G|{n %s" % line caller.msg(string) def purge_processor(caller): @@ -296,8 +296,8 @@ class CmdBatchCode(MuxCommand): if not codes: string = "'%s' not found.\nYou have to supply the python path " - string += "of the file relative to \nyour batch-file directory (%s)." - caller.msg(string % (python_path, settings.BASE_BATCHPROCESS_PATH)) + string += "of the file relative to \nyour batch-file directories (%s)." + caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS))) return switches = self.switches diff --git a/src/objects/manager.py b/src/objects/manager.py index b097b3d0d6..d83bae718e 100644 --- a/src/objects/manager.py +++ b/src/objects/manager.py @@ -191,7 +191,7 @@ class ObjectManager(TypedObjectManager): If None, the default 'key' attribute is used. location: If None, character.location will be used. """ - #ostring = str(ostring).strip() + ostring = to_unicode(ostring, force_string=True) if not ostring: return [] @@ -210,16 +210,16 @@ class ObjectManager(TypedObjectManager): if location and ostring == 'here': return [location] - if caller and to_unicode(ostring) in ('me', 'self'): + if caller and ostring in ('me', 'self'): return [caller] - if caller and to_unicode(ostring) in ('*me', '*self'): + if caller and ostring in ('*me', '*self'): return [caller] # Test if we are looking for an object controlled by a # specific player #logger.log_infomsg(str(type(ostring))) - if to_unicode(ostring).startswith("*"): + if ostring.startswith("*"): # Player search - try to find obj by its player's name player_match = self.get_object_with_player(ostring) if player_match is not None: diff --git a/src/objects/objects.py b/src/objects/objects.py index 48ed5f155a..33857a3d40 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -31,16 +31,20 @@ class Object(TypeClass): def __eq__(self, other): """ + Checks for equality against an id string or another object or user. + This has be located at this level, having it in the parent doesn't work. """ - - result = other and other.id == self.id - try: - uresult = other and (other.user.id == self.user.id) - except AttributeError: - uresult = False - return result or uresult + result = self.id == other + if not result and hasattr(other, "id"): + result = self.id == other.id + if not result: + try: + result = other and self.user.id == other.user.id + except AttributeError: + pass + return result # hooks called by the game engine diff --git a/src/utils/batchprocessors.py b/src/utils/batchprocessors.py index a2b3fc9039..88388eeebb 100644 --- a/src/utils/batchprocessors.py +++ b/src/utils/batchprocessors.py @@ -147,6 +147,7 @@ from src.utils import utils from game import settings as settings_module ENCODINGS = settings.ENCODINGS +CODE_INFO_HEADER = re.compile(r"\(.*?\)") #------------------------------------------------------------ # Helper function @@ -327,29 +328,24 @@ class BatchCodeProcessor(object): Identifies the line type: block command, comment, empty or normal code. """ - line = line.strip() + parseline = line.strip() - if line.startswith("#HEADER"): + if parseline.startswith("#HEADER"): return ("header", "", "") - elif line.startswith("#CODE"): + elif parseline.startswith("#CODE"): # parse code command line = line.lstrip("#CODE").strip() - objs = [] - info = "" - if line and '(' in line and ')' in line: - # a code description - lp = line.find('(') - rp = line.find(')') - info = line[lp:rp+1] - line = line[rp+1:] - if line: - objs = [obj.strip() for obj in line.split(',')] + info = CODE_INFO_HEADER.findall(line) or "" + if info: + info = info[0] + line = line.replace(info, "") + objs = [o.strip() for o in line.split(",") if o.strip()] return ("codeheader", info, objs) - elif line.startswith('#'): - return ('comment', "", "\n%s" % line) + elif parseline.startswith('#'): + return ('comment', "", "%s" % line) else: #normal line - return it with a line break. - return ('line', "", "\n%s" % line) + return ('line', "", "%s" % line) # read indata @@ -398,10 +394,13 @@ class BatchCodeProcessor(object): # last, we merge the headers with all codes. for codedict in codes: - codedict["code"] = "#CODE %s %s\n%s\n\n%s" % (codedict['info'], - ", ".join(codedict["objs"]), - header.strip(), - codedict["code"].strip()) + objs = ", ".join(codedict["objs"]) + if objs: + objs = "[%s]" % objs + codedict["code"] = "#CODE %s %s \n%s\n\n%s" % (codedict['info'], + objs, + header.strip(), + codedict["code"].strip()) return codes def code_exec(self, codedict, extra_environ=None, debug=False): @@ -429,7 +428,7 @@ class BatchCodeProcessor(object): # execute the block try: exec(code, environdict) - except Exception: + except Exception, e: errlist = format_exc().split('\n') if len(errlist) > 4: errlist = errlist[4:]