mtr_extra:resourcepack:make:start
Differences
This shows you the differences between two versions of the page.
| mtr_extra:resourcepack:make:start [2026/09/17 14:07] – created Survival | Anarchy | Nostalgia | mtr_extra:resourcepack:make:start [2026/09/17 14:07] (current) – expanded Survival | Anarchy | Nostalgia | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== MTR Custom Scripting: | + | ====== MTR Custom Scripting: |
| ====== Overview ====== | ====== Overview ====== | ||
| - | Briefly explain what your MTR script or code component does (e.g., train behavior | + | This page details how to implement custom JavaScript hooks using the **Minecraft Transit Railway |
| - | ====== | + | ====== Setup & Implementation |
| - | Place your code block here. Use appropriate syntax highlighting for JavaScript/JSON. | + | MTR scripts run in a JavaScript |
| - | <code javascript> | + | * PATH: assets/mtr/scripts/custom_train_logic.js |
| - | // Example MTR Script | + | |
| - | function onStart(train) { | + | |
| - | train.setName(" | + | |
| - | } | + | |
| - | </ | + | |
| - | ====== Parameters / Properties ====== | + | ==== Registering in config.json |
| + | Reference your script inside your train' | ||
| - | | Parameter | Type | Description | | + | ====== Core Script Template ====== |
| - | | :--- | :--- | :--- | | + | Below is the boilerplate code structure required |
| - | | `train` | TrainObject | Reference | + | |
| - | | `name` | String | Display name shown on destination board | | + | |
| - | ====== | + | ====== |
| - | 1. Save script inside your resource pack or addon folder under `assets/ | + | |
| - | 2. Reference the script via your custom train/ | + | |
| - | 3. Test in-game using `/mtr reload`. | + | |
| - | ====== Related Pages ====== | + | ^ Hook / Method ^ Type ^ Description ^ |
| - | * [[mtr: | + | |
| - | * [[mtr: | + | |
| + | | onTrainUpdate(train, | ||
| + | | onTrainSpawn(train) | Lifecycle Hook | Fires exactly once when a train is initialized/ | ||
| + | | train.getSpeed() | Float | Returns the current train velocity in meters per tick. | | ||
| + | | train.isStoppedAtPlatform() | Boolean | Returns true if the train is static and servicing an active station platform. | | ||
| + | | train.setCustomText(string) | Method | Overrides the destination matrix string rendered on the exterior PIDS boards. | | ||
| + | | train.setHeadlightsEnabled(bool)| Method | Manually toggles the emissive texture rendering state for train lighting arrays. | | ||
| + | |||
| + | ====== In-Game Deployment Workflow ====== | ||
| + | |||
| + | 1. Package your updated script and config.json file inside your resource pack zip/folder. | ||
| + | 2. Load Minecraft and apply the resource pack in your active packs settings menu. | ||
| + | 3. Run the in-game command %%/mtr reload%% to clear cached JavaScript runtimes and instantly push script adjustments live without a server reboot. | ||
| + | 4. Inspect the client logs (latest.log) to catch any thrown JavaScript compilation syntax errors or runtime exceptions. | ||
| + | |||
| + | ====== Related Wiki Sections ====== | ||
| + | |||
| + | * [[mtr: | ||
| + | * [[mtr: | ||
| + | * [[mtr: | ||
mtr_extra/resourcepack/make/start.txt · Last modified: 2026/09/17 14:07 by Survival | Anarchy | Nostalgia