Pack Making JSON Connections - DonBruce64/MinecraftTransportSimulator GitHub Wiki

Connections are what they sound like: connections to other vehicles. Connections come in various types and formats, but they all follow a standard idea: one vehicle has a โ€œhitchโ€ point that can connect to another vehicle's โ€œhookupโ€ point. These are at defined positions, and when connected MTS will make the two points line up. While a vehicle can tow multiple vehicles, a vehicle may only be towed by one vehicle at a time.

Connections are placed in groups. Each group may have only one vehicle connected at any given time, but multiple groups may be in use simultaneously. For example, a pickup truck may have both a normal bumper hitch and a gooseneck. These should be grouped, as only one can be in-use at a given time. Conversely, a flat-bed tow trailer can both carry a vehicle, and tow a trailer at the same time, so these would not be grouped.

Connections are activated by pressing the trailer button in the main vehicle panel, or the vehicle to be hooked up, depending on the setting of the connection group. Whichever vehicle is the one that can initiate the connection is the one that will have the button. For example, a tow truck should have a hitch and a button to connect to other vehicles, while a bomber with detachable fighters should have the hitch on the bomber but the fighter should have a hookup button.

Note that no matter how you do your connections, none may share the same position, nor may you have a connection at 0, 0, 0, so keep this in mind.

Connection Groups

Each entry in the connectionGroups contains the following:

  • name - The name of this group. Will be displayed in the panel.
  • canInitiateConnections - If set, a button will appear on the panel for making all the connections in this group.
  • canInitiateSubConnections - Normally vehicles towing vehicle/trailers can't connect or disconnect trailers on the things they are towing. If this is set, any buttons that would appear on the towed vehicle/trailer will also appear on the main vehicle's panel when connected via this group. Useful for multi-trailer semi trucks. Only works on the hookup part of the connection, as this is decided by the towed vehicle.
  • isHitch - If true, this group will be allowed to tow hookup groups.
  • isHookup - If true, this group will be allowed to tow hitch groups. Note that you can have a connection group as both a hookup and a hitch if you want connections for either. Think train couplers.
  • isSnap - If true, this group will auto-connect to any valid connections. It will only disconnect if disabled. This can be done by clicking the hitbox, or clicking the button in the panel. After going double the connection distance away, it will re-enable itself.
  • connections - The list of connections for this group.

Connections

  • type โ€“ The type of connection. This can be anything you want, but it is recommended to follow the conventions to allow your pack to be compatible with other packs wishing to use the same connection. Check the conventions Tow is a common one in use for a hitch position on vehicles that allows them to be towed by a tow truck, for example.
  • pos โ€“ The position of this connection on the vehicle.
  • rot โ€“ The rotation of this connection. Used on mounted and restricted connections. Has no effect on other connections.
  • mounted โ€“ If true, then connecting vehicles will be mounted to this point rather than dragged. Useful for things like flat-bed trailers, where you want the vehicle to stay in one place.
  • restricted - If true, then connecting vehicles will be restricted to only change in pitch, and won't allowed to yaw back and forth.
  • distance โ€“ How far away this connection can connect. Defaults to 2 blocks if not set.
  • applyAfter - If this is set, then this connection will moved based on the animations for the specified object.