chainsol icon

Untitled

chainsol | PRO | 11/25/17 07:44:49 PM UTC | 0 ⭐ | 533 👁️ | Never ⏰ | []
Python |

1.37 KB

|

None

|

0 👍

/

0 👎

class CmdExtendedGet(default_cmds.CmdGet):
    """
    pick up something
    Usage:
      get <obj>
    Picks up an object from your location and puts it in
    your inventory.
    """
    key = "get"
    aliases = "grab"
    locks = "cmd:all()"
 
    def func(self):
        """implements the command."""
 
        caller = self.caller
 
        if not self.args:
            caller.msg("Get what?")
            return
        result = caller.search(self.args,
                            location=caller.location,
                            quiet=True)
        if not result:
            caller.msg("{} not found".format(self.args))
            return
        else:
            obj = result[0]
        if caller == obj:
            caller.msg("You can't get yourself.")
            return
        if not obj.access(caller, 'get'):
            if obj.db.get_err_msg:
                caller.msg(obj.db.get_err_msg)
            else:
                caller.msg("You can't get that.")
            return
 
        obj.move_to(caller, quiet=True)
        caller.msg("You pick up %s." % obj.name)
        caller.location.msg_contents("%s picks up %s." %
                                     (caller.name,
                                      obj.name),
                                     exclude=caller)
        # calling hook method
        obj.at_get(caller)

Comments