Advertisement
Kovitikus

Search results as list and queryset

Apr 8th, 2020
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. 20-04-08 16:00:50-04 [a piece of chalk]
  2. 20-04-08 16:00:50-04 <QuerySet [basket]>
  3.  
  4. class CmdPut(Command):
  5.     """
  6.    Usage:
  7.        put <item> in <container>
  8.    
  9.    Finds an item around the character and puts it in a container.
  10.    """
  11.     key = 'put'
  12.  
  13.     def parse(self):
  14.         self.item_arg, self.container_arg = self.args.split('in')
  15.         self.item_arg = self.item_arg.strip()
  16.         self.container_arg = self.container_arg.strip()
  17.  
  18.     def func(self):
  19.         caller = self.caller
  20.         item_arg = self.item_arg
  21.         container_arg = self.container_arg
  22.  
  23.         # Find the item.
  24.         # Location unset, search conducted within the character and its location.
  25.         item = caller.search(item_arg, quiet=True)
  26.         if item:
  27.             print(item)
  28.             container = caller.search(container_arg, quiet=True)
  29.             if container:
  30.                 print(container)
  31.                 return
  32.                 # if item.location:
  33.                 #     caller.msg(f"You pick up {item.name} and place it in {container.name}.")
  34.                 #     caller.msg_contents(f"{caller.name} picks up {item.name} and places it in {container.name}.", exclude=caller)
  35.                 # elif item in caller:
  36.                 #     caller.msg(f"You place {item.name} in {container.name}.")
  37.                 #     caller.msg_contents(f"{caller.name} places {item.name} in {container.name}.", exclude=caller)
  38.                 # item.move_to(container, quiet=True)
  39.             else:
  40.                 caller.msg(f"Could not find {container_arg}!")
  41.         else:
  42.             caller.msg(f"Could not find {item_arg}!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement