Advertisement
telestrial

Untitled

Jun 13th, 2021
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. class EditCmd(Command):
  2.     """
  3.    Edit command for rooms, objects, mobs, and more! The power is in your hands.
  4.  
  5.    Usage
  6.      edit [thing] [attribute] [value]
  7.  
  8.    If no arguments are supplied, stats the current room. If only [thing] is supplied,
  9.    performs a stat command on that [thing]. With [thing] and [attribute], will attempt
  10.    to help you understand what values you can supply. The command should not let you set
  11.    things you shouldn't set....mostly.
  12.    """
  13.     key = "edit"
  14.     locks = "perm(Builders)"
  15.     help_category = "Building"
  16.  
  17.     def func(self):
  18.         if not self.args.strip():
  19.             self.msg(stat_render(self, self.caller.location))
  20.             return
  21.  
  22.         self.args = self.args.strip().split(" ", 2)
  23.         obj = self.caller.search(self.args[0], global_search=True)
  24.  
  25.         if not obj:
  26.             return
  27.  
  28.         if len(self.args) == 1:
  29.             self.msg(stat_render(self, obj))
  30.             return
  31.  
  32.         # if self.args[1] in 'description':
  33.         #     self.args[1] = 'desc'
  34.         # if self.args[1] in 'nightdescription':
  35.         #     self.args[1] = 'nightdesc'
  36.  
  37.         if len(self.args) == 2:
  38.             if not obj.attributes.has(self.args[1]):
  39.                 self.msg('{} has no atrribute: {}'.format(obj, self.args[1]))
  40.  
  41.             self.msg(obj.attributes.get(self.args[1]))
  42.  
  43.         if self.args[1] == 'desc' or self.args[1] == 'nightdesc':
  44.             def load(caller):
  45.                 "get the current value"
  46.                 return caller.attributes.get(self.args[1])
  47.  
  48.             def save(caller, buffer):
  49.                 "save the buffer"
  50.                 caller.attributes.set("{}".format(self.args[1]), buffer)
  51.  
  52.             def quit(caller):
  53.                 "Since we define it, we must handle messages"
  54.                 caller.msg("Editor exited")
  55.  
  56.             eveditor.EvEditor(self.caller,
  57.                               loadfunc=load, savefunc=save, quitfunc=quit,
  58.                               key=self.args[1], persistent=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement