Skip to content

1. Screen size & position

Lewen Choiee edited this page Sep 8, 2026 · 4 revisions

One of the most popular applications of scripting for MTR mod is to mimic real-world LCD or LED screens on vehicles. However, many people often stuck at moving it - If the screen isn't properly positioned, then you won't see it regardless of how many cool effects you've added.

Challenging, but there are hacks

Across different vehicles, the 3D model may differ significantly, so there're no simple presets to make your screen perfectly aligned to the position you want. The good news is, we'll introduce you a few helper tools, so you won't need to struggle for adjusting the parameters.

If you already got your screen positioned at a good place, you may skip to the next tutorial.

Key concept

  • Array - anything that looks like [something, something, something...]

Basic code structure

The Template Resource Pack contains the basic code structure for controlling screen positioning.

/* [SCREEN CONFIGURATIONS] */
let infoPanelConfig = {

"version": 1,
"texSize": [2000, 400],
"slots": [
{
"name": "info-panel",
"texArea": [0, 0, 2000, 400],

// "pos" controls the position of every vertex
"pos": [
[
[0.6595, 2.088, -0.4],
[0.7775, 2.02, -0.4],
[0.7775, 2.02, 0.4],
[0.6595, 2.088, 0.4]
],
[
[-0.6595, 2.088, 0.4],
[-0.7775, 2.02, 0.4],
[-0.7775, 2.02, -0.4],
[-0.6595, 2.088, -0.4]
]
],

// "offsets" controls the transform distance of the screen
"offsets": [
[0.0, 0.0, 7.5],
[0.0, 0.0, 2.5],
[0.0, 0.0, -2.5],
[0.0, 0.0, -7.5]
]
}
]

};

  • let infoPanelConfig - create a setting for the screen to use later
  • version - currently fixed as 1, might be a reserved value for NTE or JCM mod
  • texSize -
  • name - unique name of the screen, to be used later
  • texArea -
  • pos - controls the position of every vertex of the screen
  • offsets - controls the transform distance of the screen

The main challenge comes from adjusting the values in pos and offsets.

"pos" - marks the initial screen positions

The pos section looks like some nested arrays:

Level 1 (L1): "pos" = L1
Level 2 (L2): "pos" = [L2, L2]
Level 3 (L3): "pos" = [ [L3, L3, L3, L3], [L3, L3, L3, L3] ]

There are two L2 arrays. Each L2 array represents a unique position of the screen. In the case of M-Train with InfoPanels,

  • The first L2 array controls the position of the screen on the left side
  • The second L2 array controls the position of the screen on the right side

Inside each L2 array, there are 4 L3 arrays. Each L3 array controls the position of a single vertex of the screen's shape, which is a rectangle in most cases.

  • The first L3 array control the position of the upper-left vertex (Here, upper-left is in respect with the screen's shape in 2D, not the 3D train model. This also applies to other L3 arrays.)
  • The second L3 array controls the bottom-left vertex
  • The third L3 array controls the bottom-right vertex
  • The fourth L3 array controls the upper-right vertex

Inside each L3 array, there are 3 values: [value 1, value 2, value 3], representing the coordinates of a vertex in respect to the train's direction when leaving the depot.

  • Increasing value 1 moves the vertex further to left
  • Increasing value 2 moves the vertex further to up
  • Increasing value 3 moves the vertex further forward

"offsets" - for easy screen copying with same facing

In the pos section, only 2 screens are positioned: one at the left and one at the right. You might think of adding more L2 arrays in the pos section to add more screens onto the train, but in a special case, things can be done easier: if the screens that you want to add are in the same facing as the screens in the pos section, you can use offsets.

What is "same facing"

It is often seen on vehicles with repeated structures, like doors and windows. Usually, on one side of a carriage, you not only see one, but several screens, each placed on top of a door or window. These screens on the same side would share the same facing.

The offsets section can move and copy all screens defined in the pos section while keeping their facing. It contains a big array that holds 4 small arrays, each containing 3 values:

"offsets": [ [value 1, value 2, value 3], [...], [...], [...] ]

  • The number of small arrays means how many screens you want to share the same facing
  • The 3 values inside each small array controls how far to move the screen. They represent the coordinates of the screen in respect to the train's direction when leaving the depot, just like the coordinates of a vertex in the pos section.

Helper tools

Now, you might want to try adjusting the values to align with your desired position, but it's very challenging, since you need to calculate or even guess every value's relationship with your vehicle model. You'll be mind-blown with these:

How far left should it go? How far up should it go? How far forward should it go? Add 0.01? No, it's not enough. Add 0.02? No, it's going too much...

The good news is, there are some tools to help you find the values for positioning.

BlockBench and Blender

Many 3D modelling software come with a vertex control feature to let you see and modify the coordinates of every vertex. That includes:

  • BlockBench, a popular software for Minecraft content modelling
  • Blender, a more general 3D modelling software for more advanced controls than BlockBench

For .obj models, only Blender is needed. For .bbmodel models, both BlockBench and Blender are required.

Steps

  1. (.bbmodel only) Open your .bbmodel in BlockBench
  2. (.bbmodel only) Click File > Export > Export OBJ Model
  3. Import the .obj file in Blender, using Y as the forward axis, and -Z as the up axis. You'll see the train facing the sky, but this can make sure that the X, Y, and Z coordinates align with the in-game screen positioning. It is often to see 3D modelling software not sharing the same coordinate system as Minecraft and some mods

BlockBench also has vertex control feature, but only for genetic models, which is not the case for many Minecraft models. Also, BlockBench lacks some essential options for import and shape resizing, which will make the vertices of your screen hard to align with the model. So for now, we do not recommend using BlockBench for vertex positioning.

  1. Some models, especially those built-in MTR mod models, have repeated parts combined, meaning that you'll see many things cramped in one place. Find the part that you want to install the JavaScript screen and hide all other parts
  2. Create a plane
  3. Change from Object Mode to Edit Mode
  4. Now, you can select one of the vertices of the plane. Click Item on the right panel and you'll see inputs for X, Y, and Z coordinates. Adjust them to move the vertex to your desired position
  5. Tips: You can select multiple vertices with Shift key when clicking the vertices. When one or more vertices are selected, press G key to enter move mode, then move your mouse around to move the vertices

Previous: Before we start | Next: Basic shapes, images, text

Clone this wiki locally