This library is NOT compatible with MTR 4, only MTR 3.
Built-in Features
fetch(url: String)
⚠️ Internal use only. Do not use.
Performs a GET request using the provided URL.
function fetch(url) { return response }
fetchDepartures(stationID: String, url: String, port: Number, secure: Boolean)
Requires fetch()
to be imported.
Retrieves the next departures from a station using its code. Optional parameters allow you to set a custom base URL, port, and HTTPS mode. If all three are null
, it defaults to:
http://localhost:8888/arrivals?stationId=<stationID>
function fetchDepartures(stationID, url, port, secure) { return Array<Object> }
fetchDeparturesFromPlatform(stationID: String, platformID: String, url: String, port: Number, secure: Boolean)
Requires fetch()
to be imported.
Gets the next departures from a specific platform of a station. URL, port, and HTTPS are optional. Defaults to:
http://localhost:8888/arrivals?stationId=<stationID>
function fetchDeparturesFromPlatform(stationID, platformID, url, port, secure) { return Array<Object> }
fetchFirstDepartureFromPlatform(stationID: String, platformID: String, url: String, port: Number, secure: Boolean)
Requires fetch()
to be imported.
Returns only the first upcoming departure for a specific platform. Same URL behavior as above.
function fetchFirstDepartureFromPlatform(stationID, platformID, url, port, secure) { return Object }
fetchMTRData(url: String, port: Number, secure: Boolean)
Requires fetch()
to be imported.
Fetches all MTR data and combines the dimensions into one object. Optional base URL, port, and HTTPS settings apply. Defaults to:
http://localhost:8888/data
function fetchMTRData(url, port, secure) { return Object }
formatStop(stationName: String)
Formats a station name by trimming whitespace, removing emojis, and replacing single pipe characters.
If the name has multiple parts, extra names are grouped in parentheses.
- Example 1:
"East Hills||Pittsburgh|East"
→"East Hills (Pittsburgh/East)"
- Example 2:
"West Ham 🍖||Stewie||South 🧭"
→"West Ham (Stewie, South)"
function formatStop(stationName) { return String }
getCurrentFormattedTime()
⚠️ DEPRECATED: Use getTime(ms)
instead.
Returns the current time as "HH:MM"
.
function getCurrentFormattedTime() { return String }
getCurrentStation(dataset: Object, stationID: String)
⚠️ DEPRECATED: Dataset functions will be removed in future versions.
Returns the station data for a given station ID from the provided dataset.
Fails if the station is not found or if stationID
is not a string.
function getCurrentStation(dataset, stationID) { return Object }
getRemainingMinutes(arrivalTime: Number)
Returns the number of minutes remaining until the given arrival time.
Returns 0
if there's an error or if arrival is in less than 1 minute.
Fails if arrivalTime
is undefined or not a number.
function getRemainingMinutes(arrivalTime) { return Number }
getStationData(xPos: Number, zPos: Number, url: String, port: Number, secure: Boolean)
Requires fetchMTRData()
to be imported.
Returns the closest station to the given coordinates. URL, port, and HTTPS are optional. Defaults to:
http://localhost:8888/data
⚠️ Important: The MTR API won't list a station unless a route serves it. Place this script only after service has started.
function getStationData(xPos, zPos, url, port, secure) { return Object }
getStationsOfRouteFrom(dataset: Object, routeName: String, stationName: String)
⚠️ DEPRECATED: Dataset functions will be removed in future versions.
Returns a list of the remaining stations on a route from a given station.
Route and station names must match exactly with those in the MTR API.
function getStationsOfRouteFrom(dataset, routeName, stationName) { return Array<String> }
getTime(ms: Number?)
Returns the time in "HH:MM"
format.
If ms
is null
, returns the current system time.
getTime(1750843821742)
→"11:30"
getTime(null)
→"09:35"
(e.g. if run on June 25, 2025 at 09:35:14)
function getTime(ms) { return String }
Troubleshooting
Q: The scripts run slowly or produce errors on some models.
A: Low-spec computers may struggle with multiple script models. Try reducing the number of active models in the render area or lower their refresh rate.
More info: https://wiki.minecrafttransitrailway.com/mtr_addon:nte:js:eyecandy
Q: The model doesn't appear in the resource pack.
A: Reload the resource packs in-game using F3 + T
.
Q: getStationData()
does not return the nearest station.
A: Has the station already been assigned to a route and started service?
The MTR API won't recognize it until active service is detected.
External resources
Featured versions
See allProject members

JCIBravo
Owner