Advertisement
telestrial

Untitled

Jun 13th, 2021 (edited)
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.73 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 len(self.args) == 2:
  33.             if not obj.attributes.has(self.args[1]):
  34.                 self.msg('{} has no atrribute: {}'.format(obj, self.args[1]))
  35.  
  36.             if self.args[1] == 'desc' or self.args[1] == 'nightdesc':
  37.                 self.msg(obj) # Sends the correct object--room, in my test case
  38.                 self.msg('Line 89')
  39.  
  40.                 def load(obj):
  41.                     "get the current value"
  42.                     self.msg(obj) # Prints caller. My character
  43.                     return obj.attributes.get(self.args[1])
  44.  
  45.                 def save(obj, buffer):
  46.                     "save the buffer"
  47.                     obj.attributes.add("{}".format(self.args[1]), buffer)
  48.  
  49.                 def quit(caller):
  50.                     "Since we define it, we must handle messages"
  51.                     caller.msg("Editor exited")
  52.  
  53.                 eveditor.EvEditor(self.caller,
  54.                                   loadfunc=load, savefunc=save, quitfunc=quit,
  55.                                   key=self.args[1], persistent=True)
  56.                
  57. # Command--------------------------------------------------------------------
  58. # edit here desc <--command that is invoked. 'Here' is obviously current room. desc is attribute
  59. # Output---------------------------------------------------------------------
  60. # bgs_canteen
  61. # Line 89
  62. # Telestrial
  63.  
  64. # Can't pickle local object 'EditCmd.func.<locals>.load'
  65.  
  66. # The editor state could not be saved for persistent mode. Switching
  67. # to non-persistent mode (which means the editor session won't survive
  68. # an eventual server reload - so save often!)
  69.  
  70. #----------Line Editor [desc]--------------------------------------------------
  71. #01| This is User #1.
  72. #----------[l:01 w:004 c:0016]------------(:h for help)------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement