Added at_before hooks to CmdGet, CmdGive, CmdDrop
Added in references to at_before hooks for the get, give, and drop commands. If these hooks return 'False' or 'None', the action is canceled.
This commit is contained in:
parent
c3ce2ebcd7
commit
dd8e136cfc
1 changed files with 14 additions and 1 deletions
|
|
@ -266,6 +266,10 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
|
||||||
else:
|
else:
|
||||||
caller.msg("You can't get that.")
|
caller.msg("You can't get that.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# calling at_before_get hook method
|
||||||
|
if not obj.at_before_get(caller):
|
||||||
|
return
|
||||||
|
|
||||||
obj.move_to(caller, quiet=True)
|
obj.move_to(caller, quiet=True)
|
||||||
caller.msg("You pick up %s." % obj.name)
|
caller.msg("You pick up %s." % obj.name)
|
||||||
|
|
@ -273,7 +277,7 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
|
||||||
(caller.name,
|
(caller.name,
|
||||||
obj.name),
|
obj.name),
|
||||||
exclude=caller)
|
exclude=caller)
|
||||||
# calling hook method
|
# calling at_get hook method
|
||||||
obj.at_get(caller)
|
obj.at_get(caller)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -307,6 +311,10 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
|
||||||
multimatch_string="You carry more than one %s:" % self.args)
|
multimatch_string="You carry more than one %s:" % self.args)
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Call the object script's at_before_drop() method.
|
||||||
|
if not obj.at_before_drop(caller):
|
||||||
|
return
|
||||||
|
|
||||||
obj.move_to(caller.location, quiet=True)
|
obj.move_to(caller.location, quiet=True)
|
||||||
caller.msg("You drop %s." % (obj.name,))
|
caller.msg("You drop %s." % (obj.name,))
|
||||||
|
|
@ -350,6 +358,11 @@ class CmdGive(COMMAND_DEFAULT_CLASS):
|
||||||
if not to_give.location == caller:
|
if not to_give.location == caller:
|
||||||
caller.msg("You are not holding %s." % to_give.key)
|
caller.msg("You are not holding %s." % to_give.key)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# calling at_before_give hook method
|
||||||
|
if not to_give.at_before_give(caller, target):
|
||||||
|
return
|
||||||
|
|
||||||
# give object
|
# give object
|
||||||
caller.msg("You give %s to %s." % (to_give.key, target.key))
|
caller.msg("You give %s to %s." % (to_give.key, target.key))
|
||||||
to_give.move_to(target, quiet=True)
|
to_give.move_to(target, quiet=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue