Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CmdTakeFrom(Command):
- """
- Usage:
- Take <item> from <container>
- Gets an item from the container, if it's in there.
- """
- key = "take"
- def parse(self):
- try:
- # get args into 2 variables
- self.item, self.container = self.args.split("from")
- self.item = self.item.strip()
- self.container = self.container.strip()
- except:
- self.caller.msg("Syntax for 'take' is: 'take item from container.'"
- def func(self):
- try:
- caller = self.caller
- container = caller.search(self.container, location=caller.location) # Check if container is in the room.
- if container:
- item = caller.search(self.item, location=container) # Check if the item is in the container.
- else:
- caller.msg(f"{self.container} doesn't exist.")
- return False
- if item:
- item.move_to(caller, quiet=True) #move the item to the caller inventory
- caller.msg(f"You take {item} from {container}.")
- caller.location.msg_contents(f"{caller.name} takes {item} from {container}.", exclude=caller)
- return True
- else:
- caller.msg(f"{self.item} isn't in {self.container}.")
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement