

def func(self):
    'Do the digging. Inherits variables from ObjManipCommand.parse()'
    caller = self.caller
    if (not self.lhs):
        string = 'Usage: @dig[/teleport] roomname[;alias;alias...][:parent] [= exit_there'
        string += '[;alias;alias..][:parent]] '
        string += '[, exit_back_here[;alias;alias..][:parent]]'
        caller.msg(string)
        return
    room = self.lhs_objs[0]
    if (not room['name']):
        caller.msg('You must supply a new room name.')
        return
    location = caller.location
    typeclass = room['option']
    if (not typeclass):
        typeclass = settings.BASE_ROOM_TYPECLASS
    lockstring = 'control:id(%s) or perm(Immortals); delete:id(%s) or perm(Wizards); edit:id(%s) or perm(Wizards)'
    lockstring = (lockstring % (caller.dbref, caller.dbref, caller.dbref))
    new_room = create.create_object(typeclass, room['name'], aliases=room['aliases'], report_to=caller)
    new_room.locks.add(lockstring)
    alias_string = ''
    if new_room.aliases.all():
        alias_string = (' (%s)' % ', '.join(new_room.aliases.all()))
    room_string = ('Created room %s(%s)%s of type %s.' % (new_room, new_room.dbref, alias_string, typeclass))
    exit_to_string = ''
    exit_back_string = ''
    if self.rhs_objs:
        to_exit = self.rhs_objs[0]
        if (not to_exit['name']):
            exit_to_string = '\nNo exit created to new room.'
        elif (not location):
            exit_to_string = '\nYou cannot create an exit from a None-location.'
        else:
            typeclass = to_exit['option']
            if (not typeclass):
                typeclass = settings.BASE_EXIT_TYPECLASS
            new_to_exit = create.create_object(typeclass, to_exit['name'], location, aliases=to_exit['aliases'], locks=lockstring, destination=new_room, report_to=caller)
            alias_string = ''
            if new_to_exit.aliases.all():
                alias_string = (' (%s)' % ', '.join(new_to_exit.aliases.all()))
            exit_to_string = '\nCreated Exit from %s to %s: %s(%s)%s.'
            exit_to_string = (exit_to_string % (location.name, new_room.name, new_to_exit, new_to_exit.dbref, alias_string))
    if (len(self.rhs_objs) > 1):
        back_exit = self.rhs_objs[1]
        if (not back_exit['name']):
            exit_back_string = '\nNo back exit created.'
        elif (not location):
            exit_back_string = '\nYou cannot create an exit back to a None-location.'
        else:
            typeclass = back_exit['option']
            if (not typeclass):
                typeclass = settings.BASE_EXIT_TYPECLASS
            new_back_exit = create.create_object(typeclass, back_exit['name'], new_room, aliases=back_exit['aliases'], locks=lockstring, destination=location, report_to=caller)
            alias_string = ''
            if new_back_exit.aliases.all():
                alias_string = (' (%s)' % ', '.join(new_back_exit.aliases.all()))
            exit_back_string = '\nCreated Exit back from %s to %s: %s(%s)%s.'
            exit_back_string = (exit_back_string % (new_room.name, location.name, new_back_exit, new_back_exit.dbref, alias_string))
    caller.msg(('%s%s%s' % (room_string, exit_to_string, exit_back_string)))
    if (new_room and (('teleport' in self.switches) or ('tel' in self.switches))):
        caller.move_to(new_room)

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