mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 01:06:32 +01:00
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:
|
||||
caller.msg("You can't get that.")
|
||||
return
|
||||
|
||||
# calling at_before_get hook method
|
||||
if not obj.at_before_get(caller):
|
||||
return
|
||||
|
||||
obj.move_to(caller, quiet=True)
|
||||
caller.msg("You pick up %s." % obj.name)
|
||||
|
|
@ -273,7 +277,7 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
|
|||
(caller.name,
|
||||
obj.name),
|
||||
exclude=caller)
|
||||
# calling hook method
|
||||
# calling at_get hook method
|
||||
obj.at_get(caller)
|
||||
|
||||
|
||||
|
|
@ -307,6 +311,10 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
|
|||
multimatch_string="You carry more than one %s:" % self.args)
|
||||
if not obj:
|
||||
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)
|
||||
caller.msg("You drop %s." % (obj.name,))
|
||||
|
|
@ -350,6 +358,11 @@ class CmdGive(COMMAND_DEFAULT_CLASS):
|
|||
if not to_give.location == caller:
|
||||
caller.msg("You are not holding %s." % to_give.key)
|
||||
return
|
||||
|
||||
# calling at_before_give hook method
|
||||
if not to_give.at_before_give(caller, target):
|
||||
return
|
||||
|
||||
# give object
|
||||
caller.msg("You give %s to %s." % (to_give.key, target.key))
|
||||
to_give.move_to(target, quiet=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue