From 9c57e1cf7a126d0bd9a0fe1babf8bd204e8efb41 Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Tue, 10 Jul 2007 15:34:07 +0000 Subject: [PATCH] Adding some more script hooks. --- commands/general.py | 6 ++++++ scripts/basicobject.py | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/commands/general.py b/commands/general.py index 85639010eb..f6b770307c 100644 --- a/commands/general.py +++ b/commands/general.py @@ -180,6 +180,9 @@ def cmd_get(cdat): target_obj.move_to(pobject, quiet=True) session.msg("You pick up %s." % (target_obj.get_name(),)) pobject.get_location().emit_to_contents("%s picks up %s." % (pobject.get_name(), target_obj.get_name()), exclude=pobject) + + # SCRIPT: Call the object's script's a_get() method. + target_obj.get_scriptlink().a_get(pobject) def cmd_drop(cdat): """ @@ -206,6 +209,9 @@ def cmd_drop(cdat): target_obj.move_to(pobject.get_location(), quiet=True) session.msg("You drop %s." % (target_obj.get_name(),)) pobject.get_location().emit_to_contents("%s drops %s." % (pobject.get_name(), target_obj.get_name()), exclude=pobject) + + # SCRIPT: Call the object's script's a_drop() method. + target_obj.get_scriptlink().a_drop(pobject) def cmd_examine(cdat): """ diff --git a/scripts/basicobject.py b/scripts/basicobject.py index 2130d91dc0..3bb2b42d69 100644 --- a/scripts/basicobject.py +++ b/scripts/basicobject.py @@ -12,15 +12,35 @@ class BasicObject: """ self.source_obj = source_obj - def a_desc(self, looker): + def a_desc(self, actor): """ Perform this action when someone uses the LOOK command on the object. - looker: (Object) Reference to the looker + actor: (Object) Reference to the looker """ # Un-comment the line below for an example #print "SCRIPT TEST: %s looked at %s." % (looker, self.source_obj) pass + + def a_get(self, actor): + """ + Perform this action when someone uses the GET command on the object. + + actor: (Object) Reference to the person who got the object + """ + # Un-comment the line below for an example + #print "SCRIPT TEST: %s got %s." % (looker, self.source_obj) + pass + + def a_drop(self, actor): + """ + Perform this action when someone uses the GET command on the object. + + actor: (Object) Reference to the person who dropped the object + """ + # Un-comment the line below for an example + #print "SCRIPT TEST: %s got %s." % (looker, self.source_obj) + pass def class_factory(source_obj): """