User Tools

Site Tools


mtr_extra:resourcepack:make:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mtr_extra:resourcepack:make:start [2026/09/17 14:07] – created Survival | Anarchy | Nostalgiamtr_extra:resourcepack:make:start [2026/09/17 14:07] (current) – expanded Survival | Anarchy | Nostalgia
Line 1: Line 1:
-====== MTR Custom Scripting: Example Script ======+====== MTR Custom Scripting: Advanced Train Behavior & PIDS Controls ====== 
  
 ====== Overview ====== ====== Overview ======
-Briefly explain what your MTR script or code component does (e.g., train behavior override, station annunciator, or custom JSON resource hook).+This page details how to implement custom JavaScript hooks using the **Minecraft Transit Railway (MTR)** mod scripting engineScripting allows content developers to dynamically override train behaviorsmanipulate custom destination boards (PIDS), and intercept station event triggers in real-time
  
-====== Syntax / Setup ====== +====== Setup & Implementation ====== 
-Place your code block here. Use appropriate syntax highlighting for JavaScript/JSON.+MTR scripts run in a JavaScript runtime environmentTo register a custom script, place your script file in your resource pack or server addon directory: 
  
-<code javascript> +* PATH: assets/mtr/scripts/custom_train_logic.js
-// Example MTR Script JS Hook snippet +
-function onStart(train) { +
-    train.setName("Express 101"); +
-+
-</code>+
  
-====== Parameters / Properties ======+==== Registering in config.json ==== 
 +Reference your script inside your train's config.json entry: 
  
-| Parameter | Type | Description | +====== Core Script Template ====== 
-| :--- | :--- | :--- | +Below is the boilerplate code structure required to intercept MTR lifecycle hooks, manage train speed, and dynamically update the train's display systems. 
-| `train` | TrainObject | Reference to the active MTR train instance | +
-| `name` | String | Display name shown on destination board |+
  
-====== Usage Example ====== +====== API Reference ====== 
-1. Save script inside your resource pack or addon folder under `assets/mtr/scripts/`. +
-2. Reference the script via your custom train/station JSON configuration. +
-3. Test in-game using `/mtr reload`.+
  
-====== Related Pages ====== +^ Hook / Method ^ Type ^ Description ^ 
-* [[mtr:4.0.x:content_developer|MTR 4 Content Developer]] +
-* [[mtr:adding_custom_resources|Adding Custom Resources]]+
  
 +| onTrainUpdate(train, world) | Lifecycle Hook | Fires every tick for every active train running the script. |
 +| onTrainSpawn(train) | Lifecycle Hook | Fires exactly once when a train is initialized/spawned on a siding. |
 +| 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:4.0.x:content_developer|MTR 4 Content Developer Resource Manual]]
 +* [[mtr:adding_custom_resources|Adding Custom Train Models & Resource Packs]]
 +* [[mtr:scripting:pids_manipulation|Advanced PIDS Layout Design Syntax]]
mtr_extra/resourcepack/make/start.txt · Last modified: 2026/09/17 14:07 by Survival | Anarchy | Nostalgia