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):
- # get args into 2 variables
- self.item_arg, self.container_arg = self.args.split("from")
- self.item_arg = self.item_arg.strip()
- self.container_arg = self.container_arg.strip()
- def func(self):
- caller = self.caller
- container_arg = self.container_arg
- item_arg = self.item_arg
- container = caller.search(container_arg, location=caller.location, quiet=True) # Check if container is in the room.
- if container:
- item = caller.search(item_arg, location=container, quiet=True) # Check if the item is in the container.
- else:
- caller.msg(f"{container_arg} doesn't exist!")
- return
- 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)
- else:
- caller.msg(f"{item_arg} isn't in {container}!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement