diff --git a/src/commands/cmdparser.py b/src/commands/cmdparser.py index 55b6a67407..9d7d369452 100644 --- a/src/commands/cmdparser.py +++ b/src/commands/cmdparser.py @@ -59,7 +59,7 @@ def cmdparser(raw_string, cmdset, caller, match_index=None): if mindex.isdigit(): mindex = int(mindex) - 1 # feed result back to parser iteratively - return cmdparser(new_raw_string, cmdset, match_index=mindex) + return cmdparser(new_raw_string, cmdset, caller, match_index=mindex) # only select command matches we are actually allowed to call. matches = [match for match in matches if match[2].access(caller, 'cmd')] diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 2df2bc461a..fa0147bf3c 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -1014,7 +1014,7 @@ class CmdOpen(ObjManipCommand): @open - create new exit Usage: - @open [;alias;alias..][:typeclass] = [,[;alias;..][:typeclass]]] + @open [;alias;alias..][:typeclass] [,[;alias;..][:typeclass]]] = Handles the creation of exits. If a destination is given, the exit will point there. The argument sets up an exit at the @@ -1075,9 +1075,9 @@ class CmdOpen(ObjManipCommand): if exit_obj: # storing a destination is what makes it an exit! exit_obj.destination = destination - string = "Created new Exit '%s' to %s (aliases: %s)." % (exit_name, - destination.name, - exit_aliases) + string = "Created new Exit '%s' from %s to %s (aliases: %s)." % (exit_name,location.name, + destination.name, + exit_aliases) else: string = "Error: Exit '%s' not created." % (exit_name) # emit results @@ -1093,8 +1093,8 @@ class CmdOpen(ObjManipCommand): caller = self.caller if not self.args or not self.rhs: - string = "Usage: @open [;alias;alias...][:typeclass] " - string += "= [;alias..][:typeclass]]]" + string = "Usage: @open [;alias...][:typeclass][,[;alias..][:typeclass]]] " + string += "= " caller.msg(string) return @@ -1109,33 +1109,25 @@ class CmdOpen(ObjManipCommand): exit_name = self.lhs_objs[0]['name'] exit_aliases = self.lhs_objs[0]['aliases'] exit_typeclass = self.lhs_objs[0]['option'] - - dest_name = self.rhs_objs[0]['name'] + dest_name = self.rhs # first, check so the destination exists. destination = caller.search(dest_name, global_search=True) if not destination: return - # Create exit - + # Create exit ok = self.create_exit(exit_name, location, destination, exit_aliases, exit_typeclass) if not ok: # an error; the exit was not created, so we quit. return - - # We are done with exit creation. Check if we want a return-exit too. - - if len(self.rhs_objs) > 1: - back_exit_name = self.rhs_objs[1]['name'] - back_exit_aliases = self.rhs_objs[1]['name'] - back_exit_typeclass = self.rhs_objs[1]['option'] - - # Create the back-exit - self.create_exit(back_exit_name, destination, location, - back_exit_aliases, back_exit_typeclass) - - + # Create back exit, if any + if len(self.lhs_objs) > 1: + back_exit_name = self.lhs_objs[1]['name'] + back_exit_aliases = self.lhs_objs[1]['aliases'] + back_exit_typeclass = self.lhs_objs[1]['option'] + ok = self.create_exit(back_exit_name, destination, location, back_exit_aliases, back_exit_typeclass) + class CmdSetAttribute(ObjManipCommand): """ @set - set attributes @@ -1820,9 +1812,11 @@ class CmdTeleport(MuxCommand): caller.msg("You can't teleport an object inside of itself!") return # try the teleport - if obj_to_teleport.move_to(destination, quiet=tel_quietly, - emit_to_obj=caller): - caller.msg("Teleported.") + if obj_to_teleport.move_to(destination, quiet=tel_quietly, emit_to_obj=caller): + if obj_to_teleport == caller: + caller.msg("Teleported to %s." % destination.key) + else: + caller.msg("Teleported %s -> %s." % (obj_to_teleport, destination.key)) class CmdScript(MuxCommand): diff --git a/src/locks/lockfuncs.py b/src/locks/lockfuncs.py index 88a64bfb5e..5064d64b89 100644 --- a/src/locks/lockfuncs.py +++ b/src/locks/lockfuncs.py @@ -252,7 +252,7 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs): else: return False except Exception, e: - print e + #print e # this might happen if we try to compare two things that cannot be compared return False @@ -260,14 +260,13 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs): if hasattr(accessing_obj, attrname): if value: return valcompare(str(getattr(accessing_obj, attrname)), value, compare) - return getattr(accessing_obj, attrname) # will return Fail on False value etc + return bool(getattr(accessing_obj, attrname)) # will return Fail on False value etc # check attributes, if they exist - if (hasattr(accessing_obj, 'has_attribute') - and accessing_obj.has_attribute(attrname)): + if (hasattr(accessing_obj, 'has_attribute') and accessing_obj.has_attribute(attrname)): if value: return (hasattr(accessing_obj, 'get_attribute') and valcompare(accessing_obj.get_attribute(attrname), value, compare)) - return accessing_obj.get_attribute(attrname) # fails on False/None values + return bool(accessing_obj.get_attribute(attrname)) # fails on False/None values return False def objattr(accessing_obj, accessed_obj, *args, **kwargs): @@ -358,7 +357,6 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs): accessed_obj.location == accessing_obj), or if accessing_obj itself holds an object matching the given key. """ - print "holds ..." try: # commands and scripts don't have contents, so we are usually looking # for the contents of their .obj property instead (i.e. the object the @@ -369,7 +367,6 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs): contents = accessing_obj.obj.contents except AttributeError: return False - print "holds", contents, accessing_obj, accessed_obj def check_holds(objid): # helper function. Compares both dbrefs and keys/aliases. @@ -386,11 +383,11 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs): else: try: if check_holds(accessed_obj.id): - print "holds: accessed_obj.id - True" + #print "holds: accessed_obj.id - True" return True except Exception: pass - print "holds: accessed_obj.obj.id -", hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id) + #print "holds: accessed_obj.obj.id -", hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id) return hasattr(accessed_obj, "obj") and check_holds(accessed_obj.obj.id) def superuser(*args, **kwargs): diff --git a/src/locks/lockhandler.py b/src/locks/lockhandler.py index 7d05331af4..73a9e631ee 100644 --- a/src/locks/lockhandler.py +++ b/src/locks/lockhandler.py @@ -330,9 +330,11 @@ class LockHandler(object): # we have previously stored the function object and all the args/kwargs as list/dict, # now we just execute them all in sequence. The result will be a list of True/False # statements. Note that there is no eval here, these are normal command calls! - true_false = (tup[0](accessing_obj, self.obj, *tup[1], **tup[2]) for tup in func_tup) + true_false = (bool(tup[0](accessing_obj, self.obj, *tup[1], **tup[2])) for tup in func_tup) # we now input these True/False list into the evalstring, which combines them with # AND/OR/NOT in order to get the final result + #true_false = tuple(true_false) + #print accessing_obj, self.obj, access_type, true_false, evalstring, func_tup, raw_string return eval(evalstring % tuple(true_false)) else: return default diff --git a/src/objects/manager.py b/src/objects/manager.py index 40badec3e6..51d98513e4 100644 --- a/src/objects/manager.py +++ b/src/objects/manager.py @@ -145,7 +145,7 @@ class ObjectManager(TypedObjectManager): estring = "__iexact" else: estring = "__istartswith" - matches = eval("self.filter(db_key%s=ostring%s)" % (estring, lstring_key)) + matches = eval("self.filter(db_key%s=ostring%s)" % (estring, lstring_key)) if not matches: alias_matches = eval("self.model.alias_set.related.model.objects.filter(db_key%s=ostring%s)" % (estring, lstring_alias)) matches = [alias.db_obj for alias in alias_matches] diff --git a/src/objects/models.py b/src/objects/models.py index fdf1c792aa..820cbbac70 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -715,7 +715,7 @@ class ObjectDB(TypedObject): #emit_to_obj.msg(errtxt % "at_after_move()") #logger.log_trace() return False - + return True # # Object Swap, Delete and Cleanup methods diff --git a/src/objects/objects.py b/src/objects/objects.py index 0b4531a944..72055ffa79 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -464,6 +464,7 @@ class Exit(Object): cmd.key = exidbobj.db_key.strip().lower() cmd.obj = exidbobj cmd.aliases = exidbobj.aliases + cmd.locks = str(exidbobj.locks) cmd.destination = exidbobj.db_destination # create a cmdset exit_cmdset = cmdset.CmdSet(None)