diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index ed6f6d273f..65fedaf5c2 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2913,7 +2913,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): prototype = None if self.lhs: key = self.lhs - prototype = spawner.search_prototype(key=key, return_meta=True) + prototype = protlib.search_prototype(key=key) if len(prototype) > 1: caller.msg("More than one match for {}:\n{}".format( key, "\n".join(proto.get('prototype_key', '') for proto in prototype))) @@ -2921,6 +2921,10 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): elif prototype: # one match prototype = prototype[0] + else: + # no match + caller.msg("No prototype '{}' was found.".format(key)) + return olc_menus.start_olc(caller, session=self.session, prototype=prototype) return diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 59fdc7db69..1cbb81b090 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -479,25 +479,28 @@ class TestBuilding(CommandTest): self.call(building.CmdSpawn(), "/list", "Key ") # @span/edit (missing prototype) + # brings up olc menu msg = self.call( building.CmdSpawn(), '/edit') - # '@spawn: Extra switch "/edit" ignored.|Usage: @spawn or {key: value, ...}\n (2 existing prototypes. Use /list to inspect)') - assert 'Prototype wizard' in msg + assert msg.startswith('______________________________________________________________________________\n\n --- Prototype wizard --- \n\n') # @spawn/edit with valid prototype - with self.assertRaises(AttributeError): - self.call( - building.CmdSpawn(), - '/edit BALL', - '@spawn: Extra switch "/edit" ignored.|Spawned Ball(#13).') + self.call( + building.CmdSpawn(), + '/edit testball') + # TODO: OLC menu comes up but it gives no + # indication of testball prototype being + # edited ... Is this correct? + # On top of OCL being shown, msg is preceded + # by Room(#1)... + assert 'Prototype wizard' in msg # @spawn/edit with invalid prototype - with self.assertRaises(AttributeError): - self.call( - building.CmdSpawn(), - '/edit NO_EXISTS', - '@spawn: Extra switch "/edit" ignored.|No prototype named \'NO_EXISTS\'.') + msg = self.call( + building.CmdSpawn(), + '/edit NO_EXISTS', + "No prototype 'NO_EXISTS' was found.") # @spawn/examine (missing prototype) self.call(