Add additional mapping to announce_move_* hooks
This commit is contained in:
parent
4f41582127
commit
f1d34a28aa
1 changed files with 14 additions and 6 deletions
|
|
@ -1162,7 +1162,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
# return has_perm(self, destination, "can_move")
|
# return has_perm(self, destination, "can_move")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def announce_move_from(self, destination, msg=None):
|
def announce_move_from(self, destination, msg=None, mapping=None):
|
||||||
"""
|
"""
|
||||||
Called if the move is to be announced. This is
|
Called if the move is to be announced. This is
|
||||||
called while we are still standing in the old
|
called while we are still standing in the old
|
||||||
|
|
@ -1171,6 +1171,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
Args:
|
Args:
|
||||||
destination (Object): The place we are going to.
|
destination (Object): The place we are going to.
|
||||||
msg (str, optional): a replacement message.
|
msg (str, optional): a replacement message.
|
||||||
|
mapping (dict, optional): additional mapping objects.
|
||||||
|
|
||||||
You can override this method and call its parent with a
|
You can override this method and call its parent with a
|
||||||
message to simply change the default message. In the string,
|
message to simply change the default message. In the string,
|
||||||
|
|
@ -1190,16 +1191,19 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
|
|
||||||
location = self.location
|
location = self.location
|
||||||
exits = [o for o in location.contents if o.location is location and o.destination is destination]
|
exits = [o for o in location.contents if o.location is location and o.destination is destination]
|
||||||
mapping = {
|
if not mapping:
|
||||||
|
mapping = {}
|
||||||
|
|
||||||
|
mapping.update({
|
||||||
"character": self,
|
"character": self,
|
||||||
"exit": exits[0] if exits else "somwhere",
|
"exit": exits[0] if exits else "somwhere",
|
||||||
"origin": location or "nowhere",
|
"origin": location or "nowhere",
|
||||||
"destination": destination or "nowhere",
|
"destination": destination or "nowhere",
|
||||||
}
|
})
|
||||||
|
|
||||||
location.msg_contents(string, exclude=(self, ), mapping=mapping)
|
location.msg_contents(string, exclude=(self, ), mapping=mapping)
|
||||||
|
|
||||||
def announce_move_to(self, source_location, msg=None):
|
def announce_move_to(self, source_location, msg=None, mapping=None):
|
||||||
"""
|
"""
|
||||||
Called after the move if the move was not quiet. At this point
|
Called after the move if the move was not quiet. At this point
|
||||||
we are standing in the new location.
|
we are standing in the new location.
|
||||||
|
|
@ -1207,6 +1211,7 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
Args:
|
Args:
|
||||||
source_location (Object): The place we came from
|
source_location (Object): The place we came from
|
||||||
msg (str, optional): the replacement message if location.
|
msg (str, optional): the replacement message if location.
|
||||||
|
mapping (dict, optional): additional mapping objects.
|
||||||
|
|
||||||
You can override this method and call its parent with a
|
You can override this method and call its parent with a
|
||||||
message to simply change the default message. In the string,
|
message to simply change the default message. In the string,
|
||||||
|
|
@ -1239,12 +1244,15 @@ class DefaultObject(with_metaclass(TypeclassBase, ObjectDB)):
|
||||||
if origin:
|
if origin:
|
||||||
exits = [o for o in destination.contents if o.location is destination and o.destination is origin]
|
exits = [o for o in destination.contents if o.location is destination and o.destination is origin]
|
||||||
|
|
||||||
mapping = {
|
if not mapping:
|
||||||
|
mapping = {}
|
||||||
|
|
||||||
|
mapping.update({
|
||||||
"character": self,
|
"character": self,
|
||||||
"exit": exits[0] if exits else "somewhere",
|
"exit": exits[0] if exits else "somewhere",
|
||||||
"origin": origin or "nowhere",
|
"origin": origin or "nowhere",
|
||||||
"destination": destination or "nowhere",
|
"destination": destination or "nowhere",
|
||||||
}
|
})
|
||||||
|
|
||||||
destination.msg_contents(string, exclude=(self, ), mapping=mapping)
|
destination.msg_contents(string, exclude=(self, ), mapping=mapping)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue