Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EditCmd(Command):
- """
- Edit command for rooms, objects, mobs, and more! The power is in your hands.
- Usage
- edit [thing] [attribute] [value]
- If no arguments are supplied, stats the current room. If only [thing] is supplied,
- performs a stat command on that [thing]. With [thing] and [attribute], will attempt
- to help you understand what values you can supply. The command should not let you set
- things you shouldn't set....mostly.
- """
- key = "edit"
- locks = "perm(Builders)"
- help_category = "Building"
- def func(self):
- if not self.args.strip():
- self.msg(stat_render(self, self.caller.location))
- return
- self.args = self.args.strip().split(" ", 2)
- obj = self.caller.search(self.args[0], global_search=True)
- if not obj:
- return
- if len(self.args) == 1:
- self.msg(stat_render(self, obj))
- return
- if len(self.args) == 2:
- if not obj.attributes.has(self.args[1]):
- self.msg('{} has no atrribute: {}'.format(obj, self.args[1]))
- if self.args[1] == 'desc' or self.args[1] == 'nightdesc':
- self.msg(obj) # Sends the correct object--room, in my test case
- self.msg('Line 89')
- def load(obj):
- "get the current value"
- self.msg(obj) # Prints caller. My character
- return obj.attributes.get(self.args[1])
- def save(obj, buffer):
- "save the buffer"
- obj.attributes.add("{}".format(self.args[1]), buffer)
- def quit(caller):
- "Since we define it, we must handle messages"
- caller.msg("Editor exited")
- eveditor.EvEditor(self.caller,
- loadfunc=load, savefunc=save, quitfunc=quit,
- key=self.args[1], persistent=True)
- # Command--------------------------------------------------------------------
- # edit here desc <--command that is invoked. 'Here' is obviously current room. desc is attribute
- # Output---------------------------------------------------------------------
- # bgs_canteen
- # Line 89
- # Telestrial
- # Can't pickle local object 'EditCmd.func.<locals>.load'
- # The editor state could not be saved for persistent mode. Switching
- # to non-persistent mode (which means the editor session won't survive
- # an eventual server reload - so save often!)
- #----------Line Editor [desc]--------------------------------------------------
- #01| This is User #1.
- #----------[l:01 w:004 c:0016]------------(:h for help)------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement