Train Width vs Height.

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Train Width vs Height.

Post by bobingabout »

I've looked at the train stuff, the Diesel Locomotive, and Cargo wagon.
I'm sure you've all noticed that a train is longer when on Horizontal track than when on Vertical track, which can be a huge PITA when trying to design a station. Make a blueprint, rotate it, oh shit it doesn't work anymore.

So... I've been looking at the code for it.
Does anyone have any idea how the Width and Height of the entity within the game are defined? I don't seem to be able to find anything in the code that would explain why it is wider than tall.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Train Width vs Height.

Post by bobingabout »

I noticed 2 lines that seem to define the length of a vehicle. joint_distance (defines the size of the vehicle) and connection_distance (defines the space between them)

doing some quick tests here.
The default values are joint = 4.6 and connection = 3.3 for the locomotive. This gives it a width in game of 253 and a height of 200.
For a cargo wagon it's joint = 4 and connection = 3.3. This gives it a width of 234 and a height of 184 in game.
Some simple maths here... 4.6 + 3.3 = 7.9. 7.9 x 32 = 252.8, thats about 253.
4 + 3.3 = 7.3. 7.3 x 32 = 233.5, that's about 234.

I changed the connection distances of both to 4, the result was that the locomotive was 275 x 216, and the cargo wagon was 256 x 200.
Well, 4 + 4 = 8, and 8 x 32 = 256, so the cargo wagon width is 8 tiles wide.
the engine is 4.6 + 4 = 8.6. 8.6 x 32 = 275.2, so, yes, these define the width.

I then changed the distances to joint 2.6 and connection 6 for the engine, and joint 2 connection 6 for the cargo wagon.
the result was 275 x 207 for the engine and 256 x 190 for the cargo wagon.

I just can't relate the height exactly, but it does apear to be a percentage of the width, and the more of the distance that is in the connection reduces it even further.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Kikkers
Fast Inserter
Fast Inserter
Posts: 109
Joined: Sun Jun 22, 2014 8:45 pm
Contact:

Re: Train Width vs Height.

Post by Kikkers »

I've been thinking a bit about this, and I suspect the core of the issue is that the isometric projection of the game art doesn't match the square tile.

Trains seem to be the most visible expression of this issue, where you can't convincingly draw the train the same distance vertically and horizontally, without there being a very noticable distortion when they turn corners. It's because of this issue, that I have reason to believe that the train dimensions are hardcoded to match the current artstyle of the game. I think it doesn't make sense if this is a setting that can vary on a per-locomotive/wagon basis, as this ratio must hold for all train cars.

The only actual solution I can think of is to match the artstyle with the tile size, so either modify all art to a top down perspective, or make tiles non-square. In both approaches, there won't be a reason to have the ratio hardcoded (or rather, the ratio will be 1-1.

As to a short term solution? I'm not sure if there is one. Like I said, it's probably a game-wide ratio which AFAIK we can't really influence at this time in the mod api.

Post Reply

Return to “Modding discussion”