From f693d56f1471c8f652941f684c91987afc96f215 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 3 Mar 2018 19:55:37 +0100 Subject: [PATCH] Continue working with new spawn additions --- evennia/commands/default/building.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 6cbef476d4..9bc7915497 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -12,6 +12,7 @@ from evennia.commands.cmdhandler import get_and_merge_cmdsets from evennia.utils import create, utils, search from evennia.utils.utils import inherits_from, class_from_module from evennia.utils.eveditor import EvEditor +from evennia.utils.evmore import EvMore from evennia.utils.spawner import spawn, search_prototype, list_prototypes from evennia.utils.ansi import raw @@ -2736,7 +2737,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): @spawn/search [query] @spawn/list [tag, tag] - @spawn/show + @spawn/show [] @spawn/save [;desc[;tag,tag,..[;lockstring]]] @spawn/menu @@ -2746,7 +2747,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): location will default to caller's current location. search - search prototype by name or tags. list - list available prototypes, optionally limit by tags. - show - inspect prototype by key. + show - inspect prototype by key. If not given, acts like list. save - save a prototype to the database. It will be listable by /list. menu - manipulate prototype in a menu interface. @@ -2792,12 +2793,28 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): "\n" + utils.fill(prots) if prots else "None") caller = self.caller + + if 'show' in self.switches: + # the argument is a key in this case (may be a partial key) + if not self.args: + self.switches.append('list') + else: + EvMore(caller, unicode(list_prototypes(key=self.args), exit_on_lastpage=True)) + return + + if 'list' in self.switches: + # for list, all optional arguments are tags + EvMore(caller, unicode(list_prototypes(tags=self.lhslist)), exit_on_lastpage=True) + return + if not self.args: ncount = len(search_prototype()) caller.msg("Usage: @spawn or {key: value, ...}" "\n ({} existing prototypes. Use /list to inspect)".format(ncount)) return + + prototypes = spawn(return_prototypes=True) if not self.args: string = "Usage: @spawn {key:value, key, value, ... }"