Skip to main content

# Script Management

## Import Scripts into the Control Center​

1. Open `File Manager → Script Directory`.
2. Drag local script files, script folders, or full flat-script folders into the file manager.
3. Uploaded scripts automatically appear in the main script picker and can be selected right away.
4. If you have many scripts, you can create folders in `Script Directory` to organize them.

## What Is a Flat Script?​

The most convenient script format for the control center is a flat script, which is a folder containing `lua/scripts/main.lua` or `lua/scripts/main.xxt`. For example:

    My Script/
    ├── res/
    │   ├── icon.png
    │   └── sample.png
    └── lua/
        ├── helper.lua
        └── scripts/
            ├── main.lua
            └── main.json

When you upload this kind of folder, the control center treats it as one runnable script package. When deployed to a device, the folder is expanded by path, and `main.lua` or `main.xxt` is used as the entry point.

## Launching and Stopping Scripts​

1. Select a script in the main script picker.
2. Select one or more target devices in the device list.
3. Click Launch Script on the action bar. The control center uploads the script to each device and starts it.
4. If needed, use Stop Script on the same action bar.

If selected groups already have default scripts bound, those group scripts take priority over the script currently chosen on the action bar. See Group Management for the full rule set.

## Upload Script to Devices / Select Script on Devices​

- Upload script to devices: sends a selected script, or all local scripts, to devices without starting them.
- Select script on devices: changes the currently selected script on the device side without starting it.

## Add a Configuration UI to a Script​

1. In `File Manager → Script Directory`, right-click a flat script folder.
2. Choose `Edit Script UI Configuration`.
3. Use the Script UI Editor to maintain `lua/scripts/main.json`.
4. Back on the main screen, if the script has a configuration UI, a Configure button appears next to the script picker.

The same script can use its default `main.json` settings, and it can also keep separate group-specific settings.

## Updating XXTLanControl.lua​

- In `Settings → Script Run Settings`, you can control whether `XXTLanControl.lua` is uploaded automatically before running scripts.
- The same panel also provides an Update Now action to replace existing `XXTLanControl.lua` files inside flat scripts with the version bundled in the current control center.