diff --git a/cmdhandler.py b/cmdhandler.py index 5238e35da0..56939f0915 100755 --- a/cmdhandler.py +++ b/cmdhandler.py @@ -164,7 +164,9 @@ def handle(cdat): cdat['uinput'] = parsed_input # SCRIPT: See if the player can traverse the exit - if not targ_exit.get_scriptlink().default_lock(pobject): + if not targ_exit.get_scriptlink().default_lock({ + "pobject": pobject + }): session.msg("You can't traverse that exit.") else: pobject.move_to(targ_exit.get_home()) diff --git a/commands/general.py b/commands/general.py index b6193f9d25..9bde8b025b 100644 --- a/commands/general.py +++ b/commands/general.py @@ -119,7 +119,9 @@ def cmd_look(cdat): })) # SCRIPT: Call the object's script's a_desc() method. - target_obj.get_scriptlink().a_desc(pobject) + target_obj.get_scriptlink().a_desc({ + "target_obj": pobject + }) def cmd_get(cdat): """ @@ -156,7 +158,9 @@ def cmd_get(cdat): 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) + target_obj.get_scriptlink().a_get({ + "pobject": pobject + }) def cmd_drop(cdat): """ @@ -185,7 +189,9 @@ def cmd_drop(cdat): 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) + target_obj.get_scriptlink().a_drop({ + "pobject": pobject + }) def cmd_examine(cdat): """ diff --git a/scripts/basicobject.py b/scripts/basicobject.py index ea5ffe356b..8903d02167 100644 --- a/scripts/basicobject.py +++ b/scripts/basicobject.py @@ -14,18 +14,25 @@ class BasicObject: """ self.source_obj = source_obj - def a_desc(self, actor): + def a_desc(self, values): """ Perform this action when someone uses the LOOK command on the object. - actor: (Object) Reference to the looker + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Un-comment the line below for an example - #print "SCRIPT TEST: %s looked at %s." % (actor, self.source_obj) + #print "SCRIPT TEST: %s looked at %s." % (values["pobject"], self.source_obj) pass def return_appearance(self, values): - target_obj = values["target_obj"] + """ + Returns a string representation of an object's appearance when LOOKed at. + + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. + """ + target_obj = self.source_obj pobject = values["pobject"] retval = "\r\n%s\r\n%s" % ( target_obj.get_name(), @@ -60,55 +67,60 @@ class BasicObject: return retval - def a_get(self, actor): + def a_get(self, values): """ Perform this action when someone uses the GET command on the object. - actor: (Object) Reference to the person who got the object + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Un-comment the line below for an example - #print "SCRIPT TEST: %s got %s." % (actor, self.source_obj) + #print "SCRIPT TEST: %s got %s." % (values["pobject"], self.source_obj) pass - def a_drop(self, actor): + def a_drop(self, values): """ Perform this action when someone uses the GET command on the object. - actor: (Object) Reference to the person who dropped the object + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Un-comment the line below for an example - #print "SCRIPT TEST: %s got %s." % (actor, self.source_obj) + #print "SCRIPT TEST: %s dropped %s." % (values["pobject"], self.source_obj) pass - def default_lock(self, actor): + def default_lock(self, values): """ This method returns a True or False boolean value to determine whether the actor passes the lock. This is generally used for picking up objects or traversing exits. - actor: (Object) Reference to the person attempting an action + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Assume everyone passes the default lock by default. return True - def use_lock(self, actor): + def use_lock(self, values): """ This method returns a True or False boolean value to determine whether the actor passes the lock. This is generally used for seeing whether a player can use an object or any of its commands. - actor: (Object) Reference to the person attempting an action + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Assume everyone passes the use lock by default. return True - def enter_lock(self, actor): + def enter_lock(self, values): """ This method returns a True or False boolean value to determine whether the actor passes the lock. This is generally used for seeing whether a player can enter another object. - actor: (Object) Reference to the person attempting an action + values: (Dict) Script arguments with keys: + * pobject: The object requesting the action. """ # Assume everyone passes the enter lock by default. return True