From 6a13d07c552e961a9a2d11f9bd5ac8a36f39a0df Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 14 Feb 2011 18:31:16 +0000 Subject: [PATCH] Fixed some hooks to match wiki docs. --- game/gamesrc/objects/baseobjects.py | 14 ++++++++++++++ src/objects/objects.py | 4 ++-- src/players/models.py | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/game/gamesrc/objects/baseobjects.py b/game/gamesrc/objects/baseobjects.py index 9ff2ea8406..778796e4ec 100644 --- a/game/gamesrc/objects/baseobjects.py +++ b/game/gamesrc/objects/baseobjects.py @@ -71,10 +71,24 @@ class Object(BaseObject): at_object_receive(obj, source_location) - called when this object receives another object (e.g. a room being entered, an object moved into inventory) + + + return_appearance(looker) - by default, this is used by the 'look' command to request this object to describe itself. Looker is the object requesting to get the information. at_desc(looker=None) - by default called whenever the appearance is requested. + + at_msg_receive(self, msg, from_obj=None, data=None) - called whenever someone sends a message to this object. + message aborted if hook returns False. + at_msg_send(self, msg, to_obj=None, data=None) - called when this objects sends a message. This can only be + called if from_obj is specified in the call to msg(). + at_object_delete() - calleed when this object is to be deleted. If returns False, deletion is aborted. + + at_get(getter) - called after object has been picked up. Does not stop pickup. + at_drop(dropper) - called when this object has been dropped. + at_say(speaker, message) - by default, called if an object inside this object speaks + """ pass diff --git a/src/objects/objects.py b/src/objects/objects.py index 8c7190b497..352f69c4c8 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -230,7 +230,7 @@ class Object(TypeClass): string += ", ".join(things) return string - def at_msg_receive(self, msg, from_obj=None): + def at_msg_receive(self, msg, from_obj=None, data=None): """ This hook is called whenever someone sends a message to this object. @@ -249,7 +249,7 @@ class Object(TypeClass): """ return True - def at_msg_send(self, msg, to_obj): + def at_msg_send(self, msg, to_obj=None, data=None): """ This is a hook that is called when /this/ object sends a message to another object with obj.msg() diff --git a/src/players/models.py b/src/players/models.py index 4dc52bc073..4c5fabe425 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -258,11 +258,11 @@ class PlayerDB(TypedObject): """ if from_obj: try: - from_obj.at_msg_send(outgoing_string, self) + from_obj.at_msg_send(outgoing_string, to_obj=self, data=data) except Exception: pass if self.character: - if self.character.at_msg_receive(outgoing_string, from_obj): + if self.character.at_msg_receive(outgoing_string, from_obj=from_obj, data=data): for session in object.__getattribute__(self, 'sessions'): session.msg(outgoing_string, data)