

def func(self):
    'Implements the spawner'

    def _show_prototypes(prototypes):
        'Helper to show a list of available prototypes'
        string = '\nAvailable prototypes:\n %s'
        string = (string % utils.fill(', '.join(sorted(prototypes.keys()))))
        return string
    prototypes = spawn(return_prototypes=True)
    if (not self.args):
        string = 'Usage: @spawn {key:value, key, value, ... }'
        self.caller.msg((string + _show_prototypes(prototypes)))
        return
    try:
        prototype = _convert_from_string(self, self.args)
    except SyntaxError:
        string = '{RCritical Python syntax error in argument. '
        string += 'Only primitive Python structures are allowed. '
        string += '\nYou also need to use correct Python syntax. '
        string += 'Remember especially to put quotes around all '
        string += 'strings inside lists and dicts.{n'
        self.caller.msg(string)
        return
    if isinstance(prototype, basestring):
        keystr = prototype
        prototype = prototypes.get(prototype, None)
        if (not prototype):
            string = ("No prototype named '%s'." % keystr)
            self.caller.msg((string + _show_prototypes(prototypes)))
            return
    elif (not isinstance(prototype, dict)):
        self.caller.msg('The prototype must be a prototype key or a Python dictionary.')
        return
    if ((not ('noloc' in self.switches)) and (not ('location' in prototype))):
        prototype['location'] = self.caller.location
    for obj in spawn(prototype):
        self.caller.msg(('Spawned %s.' % obj.get_display_name(self.caller)))

dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py CmdSpawn.func/original