Pack Making JSON Instruments - DonBruce64/MinecraftTransportSimulator GitHub Wiki

Instruments are most likely something you won't be messing with unless you really don't like the stock options available in the Official Content Pack. Should you want to make your own, pay close attention to this section. The instrument system is powerful, yet somewhat complex, making it easy to slip up in the JSON file and end up with a tachometer that looks like something clobbered together with spare parts.

Inherited JSON

Instruments inherit the following core JSON sections:

Main Section

  • components - A listing of components for this instrument. MTS iterates through all the component sections when rendering instruments, so however you set them is how the instrument will render. Each instrument component represents a single rendering of a texture from the specified instrument PNG file. These components may be modified in multiple ways. The standard way is for them to be rotated, translated, made invisible, have their lighting changed, or change what sections of the texture sheet they are pulling their texture from.
  • textureName - The texture sheet to pull this instrument from. By default, MTS will use instruments.png. This is in the main textures folder. You may use sub-folders here if you wish, but for all files MTS expects a 1024x1024 resolution. Use other resolutions at your own risk.

Components

  • xCenter – The center position to render this instrument component. By default components will be centered at the center of the instrument, but you can specify this parameter to have the component render to the left or right of the center point.
  • yCenter – Same as above, but for the y coordinate.
  • scale – The optional scale to render this component at. If not included, then the scale will be 1.0.
  • textureXCenter – This is the center of the texture location on the texture sheet. Units are in pixels.
  • textureYCenter – Same as above, but for the y coordinate.
  • textureWidth – The width, in pixels, of the texture section to render.
  • textureHeight – The height, in pixels, of the texture section to render.
  • textObject – An optional text object. If this textObject is set, then rendering off the instrument texture will not be performed. Instead, text will be rendered using the parameters from the textObject. Scale is such that 1px text == 1px of the instrument texture.
  • textFactor – The factor to multiply the the returned value of the textObject's fieldName before displaying it. Has no effect if no textObject is given.
  • animations – This is a list of animations that can be used to move this instrument based on the animation values. Since instruments are 2D, only the z-axis is supported for rotation. Similarly, only x and y translation is possible. Additionally, the instrument Y-axis aligns with the y-axis of texture sheets. Therefore, the +Y direction is down, and 0,0 is top-left.
  • rotateWindow – Normally MTS will get the texture based on the width and height specified and rotate that around the center point. However, there may be a case, such as an instrument without a bezel, where you want the region of texture you're grabbing from the texture sheet to rotate, and the rendering of that texture to stay fixed. If that is the case, set this value to true. Note that if an animation has a non-zero center point, then the window will be rotated about that center point, not 0, 0. This allows for a window that renders the outside of a dial, or other complex rotations.
  • extendWindow – Normally MTS tries to move the region of grabbed texture for translation. If instead you want to change how much texture is grabbed, set this to true. In this mode, MTS will move the upper bound of grabbed texture up by the translationVariable amount rather than offset the grabbed region.
  • moveComponent – Normally MTS tries to move the region of grabbed texture for translation. If instead you want to move the location of where the texture is rendered, you can set this to be true. This will lock the rendered window section in-place, and instead apply translations to the actual texture rendered position.
  • lightUpTexture – If this is true, MTS will make this texture bright when the lights on the vehicle are on. This can be combined with overlays to make faux-instrument lighting.
  • overlayTexture – If this is true, MTS will render the texture of this section as an overlay. This does blending on what is rendered below it, though it does not make much of a difference in lighting. If you want to make a part of an instrument bright, a lightUpTexture is probably the better option. This overlay is mainly for adding things like instrument glass effects or lighting hues. Both of these can be combined, however, to give a lighting area of effect for things like dash lights.