From 9dc9df422721c0c0bfd3a1161655a40661b419c7 Mon Sep 17 00:00:00 2001 From: Tehom Date: Sun, 18 Jun 2017 17:21:33 -0400 Subject: [PATCH 1/2] Pass kwargs needed to overriding announce_move_to and announce_move_from in move_to --- evennia/objects/objects.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 4d9bb05c2f..1c9b645cb5 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -614,7 +614,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): obj.msg(text=(outmessage, outkwargs), from_obj=from_obj, **kwargs) def move_to(self, destination, quiet=False, - emit_to_obj=None, use_destination=True, to_none=False, move_hooks=True): + emit_to_obj=None, use_destination=True, to_none=False, move_hooks=True, + msg=None, mapping=None): """ Moves this object to a new location. @@ -634,6 +635,8 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): move_hooks (bool): If False, turn off the calling of move-related hooks (at_before/after_move etc) with quiet=True, this is as quiet a move as can be done. + msg (str, optional): a replacement message. + mapping (dict, optional): additional mapping objects. Returns: result (bool): True/False depending on if there were problems with the move. @@ -700,7 +703,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): if not quiet: # tell the old room we are leaving try: - self.announce_move_from(destination) + self.announce_move_from(destination, msg=msg, mapping=mapping) except Exception as err: logerr(errtxt % "at_announce_move()", err) return False @@ -715,7 +718,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): if not quiet: # Tell the new room we are there. try: - self.announce_move_to(source_location) + self.announce_move_to(source_location, msg=msg, mapping=mapping) except Exception as err: logerr(errtxt % "announce_move_to()", err) return False From 20a576a6d92af14bbd122b0b7ca36c308d968867 Mon Sep 17 00:00:00 2001 From: Tehom Date: Sun, 25 Jun 2017 02:40:53 -0400 Subject: [PATCH 2/2] Convert to kwargs as suggested. --- evennia/objects/objects.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index 1c9b645cb5..cffb2e7cdf 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -615,7 +615,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): def move_to(self, destination, quiet=False, emit_to_obj=None, use_destination=True, to_none=False, move_hooks=True, - msg=None, mapping=None): + **kwargs): """ Moves this object to a new location. @@ -635,8 +635,9 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): move_hooks (bool): If False, turn off the calling of move-related hooks (at_before/after_move etc) with quiet=True, this is as quiet a move as can be done. - msg (str, optional): a replacement message. - mapping (dict, optional): additional mapping objects. + + Kwargs: + Passed on to announce_move_to and announce_move_from hooks. Returns: result (bool): True/False depending on if there were problems with the move. @@ -703,7 +704,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): if not quiet: # tell the old room we are leaving try: - self.announce_move_from(destination, msg=msg, mapping=mapping) + self.announce_move_from(destination, **kwargs) except Exception as err: logerr(errtxt % "at_announce_move()", err) return False @@ -718,7 +719,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)): if not quiet: # Tell the new room we are there. try: - self.announce_move_to(source_location, msg=msg, mapping=mapping) + self.announce_move_to(source_location, **kwargs) except Exception as err: logerr(errtxt % "announce_move_to()", err) return False