Fixed some hooks to match wiki docs.

This commit is contained in:
Griatch 2011-02-14 18:31:16 +00:00
parent 923b9ac2ec
commit 6a13d07c55
3 changed files with 18 additions and 4 deletions

View file

@ -71,10 +71,24 @@ class Object(BaseObject):
at_object_receive(obj, source_location) - called when this object receives another object at_object_receive(obj, source_location) - called when this object receives another object
(e.g. a room being entered, an object moved into inventory) (e.g. a room being entered, an object moved into inventory)
return_appearance(looker) - by default, this is used by the 'look' command to return_appearance(looker) - by default, this is used by the 'look' command to
request this object to describe itself. Looker request this object to describe itself. Looker
is the object requesting to get the information. is the object requesting to get the information.
at_desc(looker=None) - by default called whenever the appearance is requested. 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 pass

View file

@ -230,7 +230,7 @@ class Object(TypeClass):
string += ", ".join(things) string += ", ".join(things)
return string 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 This hook is called whenever someone
sends a message to this object. sends a message to this object.
@ -249,7 +249,7 @@ class Object(TypeClass):
""" """
return True 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 This is a hook that is called when /this/ object
sends a message to another object with obj.msg() sends a message to another object with obj.msg()

View file

@ -258,11 +258,11 @@ class PlayerDB(TypedObject):
""" """
if from_obj: if from_obj:
try: try:
from_obj.at_msg_send(outgoing_string, self) from_obj.at_msg_send(outgoing_string, to_obj=self, data=data)
except Exception: except Exception:
pass pass
if self.character: 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'): for session in object.__getattribute__(self, 'sessions'):
session.msg(outgoing_string, data) session.msg(outgoing_string, data)