

def func(self):
    'Do stuff'
    caller = self.caller
    if (not self.args):
        string = 'Usage: @script[/switch] <obj> [= <script.path or script key>]'
        caller.msg(string)
        return
    if (not self.lhs):
        caller.msg('To create a global script you need {w@scripts/add <typeclass>{n.')
        return
    obj = caller.search(self.lhs)
    if (not obj):
        return
    string = ''
    if (not self.rhs):
        scripts = obj.scripts.all()
        if (not scripts):
            string += ('No scripts defined on %s.' % obj.get_display_name(caller))
        elif (not self.switches):
            from evennia.commands.default.system import format_script_list
            string += format_script_list(scripts)
        elif ('start' in self.switches):
            num = sum([obj.scripts.start(script.key) for script in scripts])
            string += ('%s scripts started on %s.' % (num, obj.get_display_name(caller)))
        elif ('stop' in self.switches):
            for script in scripts:
                string += ('Stopping script %s on %s.' % (script.get_display_name(caller), obj.get_display_name(caller)))
                script.stop()
            string = string.strip()
        obj.scripts.validate()
    elif (not self.switches):
        ok = obj.scripts.add(self.rhs, autostart=True)
        if (not ok):
            string += ('\nScript %s could not be added and/or started on %s.' % (self.rhs, obj.get_display_name(caller)))
        else:
            string = ('Script {w%s{n successfully added and started on %s.' % (self.rhs, obj.get_display_name(caller)))
    else:
        paths = ([self.rhs] + [('%s.%s' % (prefix, self.rhs)) for prefix in settings.TYPECLASS_PATHS])
        if ('stop' in self.switches):
            for path in paths:
                ok = obj.scripts.stop(path)
                if (not ok):
                    string += ('\nScript %s could not be stopped. Does it exist?' % path)
                else:
                    string = 'Script stopped and removed from object.'
                    break
        if ('start' in self.switches):
            for path in paths:
                ok = obj.scripts.start(path)
                if (not ok):
                    string += ('\nScript %s could not be (re)started.' % path)
                else:
                    string = 'Script started successfully.'
                    break
    caller.msg(string.strip())

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