chainsol

Untitled

Nov 25th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. class CmdExtendedGet(default_cmds.CmdGet):
  2.     """
  3.    pick up something
  4.    Usage:
  5.      get <obj>
  6.    Picks up an object from your location and puts it in
  7.    your inventory.
  8.    """
  9.     key = "get"
  10.     aliases = "grab"
  11.     locks = "cmd:all()"
  12.  
  13.     def func(self):
  14.         """implements the command."""
  15.  
  16.         caller = self.caller
  17.  
  18.         if not self.args:
  19.             caller.msg("Get what?")
  20.             return
  21.         result = caller.search(self.args,
  22.                             location=caller.location,
  23.                             quiet=True)
  24.         if not result:
  25.             caller.msg("{} not found".format(self.args))
  26.             return
  27.         else:
  28.             obj = result[0]
  29.         if caller == obj:
  30.             caller.msg("You can't get yourself.")
  31.             return
  32.         if not obj.access(caller, 'get'):
  33.             if obj.db.get_err_msg:
  34.                 caller.msg(obj.db.get_err_msg)
  35.             else:
  36.                 caller.msg("You can't get that.")
  37.             return
  38.  
  39.         obj.move_to(caller, quiet=True)
  40.         caller.msg("You pick up %s." % obj.name)
  41.         caller.location.msg_contents("%s picks up %s." %
  42.                                      (caller.name,
  43.                                       obj.name),
  44.                                      exclude=caller)
  45.         # calling hook method
  46.         obj.at_get(caller)
Advertisement
Add Comment
Please, Sign In to add comment