# TIDS Timetable Generator HTML Guide
**Target file:** `timetable_editor.html`  
**Purpose:** Use a visual editor to create the timetable JSON required by the standard TIDS, and generate the `setting` JSON that should be pasted into the command block.  
## Start Here
This HTML file is a timetable editor for regular users. It avoids the need to write the complex `list` array by hand.

You will use two outputs:
- **Timetable JSON:** for example `demo_list.json`, placed where Minecraft can read it.
- **setting JSON:** copied with the "Copy setting" button, then pasted into the command block directly below the TIDS.

The deco TIDS is mainly decorative and does not read the timetable list. This HTML editor is mainly for the standard TIDS.

## How to Open
1. Find `timetable_editor.html` in this folder.
2. Open it with a browser. Double-clicking the file is usually enough; no local server is required.
3. Use the language selector in the upper-right corner to choose Traditional Chinese, Simplified Chinese, Japanese, or English.
4. Chrome, Edge, Firefox, or another modern browser is recommended.

## Switching Language
1. Find the language dropdown in the upper-right corner.
2. Choose Traditional Chinese, Simplified Chinese, Japanese, or English.
3. This changes only the editor interface text. The exported JSON format does not change.
4. If you have already edited data, switching language will not clear the current table.

## Basic Workflow
1. Click "Sample" to load built-in data, or click "New" to create a blank timetable.
2. Edit each train row in the table on the left.
3. Click "Sort" to sort by departure time, or drag the row handle to reorder manually.
4. In "Command Block setting" on the right, fill in `timeZone`, `platform`, download name, `filePath`, `realTime`, and `autoClear`.
5. Click "Download JSON" to save the timetable file.
6. Put the downloaded JSON at the location specified by `filePath`.
7. Click "Copy setting", then paste the copied content into the command block within 32 blocks directly below the TIDS.
8. Return to the game and check that the TIDS displays correctly.

## Importing an Existing Timetable
There are two ways to import:
- Click "Choose JSON File" and select an existing timetable JSON.
- Paste JSON text into the import box, then click "Import Text".

The imported JSON must contain a top-level `list` field:

```json
{
    "list": [
        [ "2005", "Changhua", "MountainLine", "FastLocal", "5:24:00", "3A", true ]
    ]
}
```

## Table Fields
- **Train No.:** 1 to 4 digits, for example `1107`.
- **Destination:** Select from the dropdown. The editor uses only destinations supported by the script.
- **Via:** Select from the dropdown. Choose "Do not show" if no route should be displayed.
- **Train Type:** Select from the dropdown, such as Local or FastLocal.
- **Departure Time:** Split into hour, minute, and second. Hour is `0-23`; minute and second are `0-59`.
- **Platform:** The platform shown in the train list, such as `1`, `2`, `3A`, or `3B`.
- **Passed:** A boolean field exported to JSON. For normal use, leave it as `true`.

Only rows that pass validation are exported to JSON. The row count, exportable count, and error count at the top of the editor show the current state.

## Editing Actions
- **+ Add Row:** Add one blank train row.
- **+5:** Add five blank train rows.
- **Duplicate icon:** Duplicate the row, useful for similar trains.
- **Delete icon:** Delete the row.
- **Drag reorder:** Drag the handle at the start of the row, move it to the target position, and release.
- **Sort:** Sort rows by departure time from earliest to latest.
- **Remove Invalid:** Remove rows with incomplete or unsupported data.

TIDS scans `list` from top to bottom and displays trains that match the time conditions, so row order affects the in-game display. Sorting by departure time is recommended for normal use.

## Right-Side setting Fields
- **timeZone:** Timezone used in real-time mode. Use `8` for Taiwan.
- **platform:** The fixed platform sign shown on the TIDS body, such as `1`, `1a`, `1b`, `2`, `2a`, `2b`, `3`, `3a`, `3b`, `4`, `4a`, or `4b`.
- **Download name:** File name used when clicking "Download JSON". If `.json` is missing, the editor adds it automatically.
- **filePath:** Path used by the in-game TIDS to read the timetable JSON. This must point to the real location of your JSON file.
- **realTime:** `true` uses real-world time; `false` uses in-game time.
- **autoClear:** Keep this as `false` for now.

## Download Name vs filePath
"Download name" only controls the file name saved by the browser. `filePath` controls where the game reads the file. They do not have to be the same, but keeping them aligned is easiest at first.

Simplest setup:
1. Set the download name to `demo_list.json`.
2. Set `filePath` to `./demo_list.json`.
3. Put the downloaded `demo_list.json` into the `.minecraft` folder.

If you want to use a subfolder such as `.minecraft/TIDS/station_a.json`:
1. Set the download name to `station_a.json`.
2. Set `filePath` to `./TIDS/station_a.json`.
3. Put the file into `.minecraft/TIDS/`.

For Windows absolute paths, `/` is recommended:

```json
"filePath": "C:/Users/Name/.minecraft/TIDS/station_a.json"
```

If you use backslashes, they must be escaped as `\\` in JSON:

```json
"filePath": "C:\\Users\\Name\\.minecraft\\TIDS\\station_a.json"
```

## Copying setting
After clicking "Copy setting", you will get content like this:

```json
{
    "setting": {
        "timeZone": 8,
        "filePath": "./demo_list.json",
        "autoClear": false,
        "realTime": true,
        "platform": "4"
    }
}
```

Paste the entire block into the command block. Do not put quotes around `true` or `false`, and do not add a trailing comma after the last field.

## Using It In Game
1. Place a standard TIDS object.
2. Place a command block directly below the TIDS, within 32 blocks on the same vertical line.
3. Paste the JSON from "Copy setting" into the command block.
4. Put the timetable JSON from "Download JSON" at the location specified by `filePath`.
5. After editing the JSON, TIDS usually reloads it automatically. You normally do not need to place the TIDS again.

Placement concept:

```text
[TIDS object]
    |
    | Directly below on the same vertical line, up to 32 blocks
    |
[Command Block]   Required, stores setting JSON
[Stained Glass]   Optional, controls approaching indicators
```

## Passed Field
"Passed" is exported as the 7th field of each timetable row. For normal use, leave it as `true`. If you only need a fixed timetable display, you usually do not need to adjust this field.

## Troubleshooting
### TIDS shows File Not Found
- Confirm that the JSON file is really at the path specified by `filePath`.
- For first tests, use `./demo_list.json` and put the file into `.minecraft`.
- Check file name casing and the `.json` extension.

### Import fails or list is not an array
- The JSON top level must be an object and must contain `list`.
- Each timetable row must be an array.
- Do not use Chinese-style quotation marks.
- Do not leave a trailing comma after the last field.

### Some rows are not exported
- Only exportable rows are included in JSON.
- Check "Messages" on the right and fix unsupported destinations, routes, train types, times, or platform formats.

### Display order is not as expected
- Click "Sort" to order by departure time.
- If you need a special order, use drag reorder.
- Confirm that `realTime` matches the time source you want.

### Copy buttons do not copy automatically
Some browsers restrict clipboard access for local HTML files. If the editor says the content has been selected, press `Ctrl+C` manually.

## Recommended Work Style
1. Click "Sample" first to confirm the browser and editor work.
2. Set the download name and `filePath`.
3. Edit a few rows, download JSON, and test in game.
4. After TIDS can read the file, finish the full timetable.
5. After large edits, click "Sort" before downloading the final JSON.
