diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index f9b87a088..bee4f3efe 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -515,26 +515,68 @@ class CmdDesc(MuxCommand): """ describe an object - Usage: + Usage 1: @desc [ =] >description> - Setts the "desc" attribute on an + Sets the "desc" attribute on an object. If an object is not given, describe the current room. + + Usage 2: + @desc/edit [obj] + + Opens up a line editor to set the "desc" + attribute on an object for advanced editing. """ key = "@desc" aliases = "@describe" locks = "cmd:perm(desc) or perm(Builders)" help_category = "Building" + def edit_handler(self): + if self.rhs: + self.msg("{rYou may specify a description, or use the edit switch, " + "but not both.{n") + return + if self.args: + obj = self.caller.search(self.args) + else: + obj = self.caller.location or self.msg("{rYou can't describe oblivion.{n") + if not obj: + return + + def load(): + return obj.db.desc or "" + + def save(): + """ + Save line buffer to the desc prop. This should + return True if successful and also report its status to the user. + """ + obj.db.desc = self.editor.buffer + self.caller.msg("Saved.") + return True + + self.editor = utils.get_line_editor()( + self.caller, + loadfunc=load, + savefunc=save, + key="desc", + ) + return + def func(self): "Define command" caller = self.caller - if not self.args: + if not self.args and 'edit' not in self.switches: caller.msg("Usage: @desc [ =] >description>") return + if 'edit' in self.switches: + self.edit_handler() + return + if self.rhs: # We have an = obj = caller.search(self.lhs) @@ -542,9 +584,11 @@ class CmdDesc(MuxCommand): return desc = self.rhs else: - obj = caller.location + obj = caller.location or self.msg("{rYou can't describe oblivion.{n") + if not obj: + return desc = self.args - # storing the description + obj.db.desc = desc caller.msg("The description was set on %s." % obj.key)