Shuttle Train Refresh

by StefanT

Train management for personal transportation with some new concepts.

Content
7 months ago
1.1
3.69K
Trains

b Compatibility with Automatic Train Painter equipment grid [implemented]

1 year, 10 months ago

Hello,

I have ran into an issue where shuttle train modules cannot be inserted into locomotive equipment grid with the following combination of mods:

The Automatic Train Painter mod provides an equipment grid of its own (which can be made larger than Shuttle Train Refresh one), and the problem happens when that particular equipment grid gets enabled, while Shuttle Train Refresh one gets disabled.

The reason I have been changing the mod settings is in order to be able to insert both the Manual Color Module and Shuttle train module into locomotive (so my personal shuttle train would have fixed colour mask).

I am mentioning the Fluid Wagon Color Mask mod as well, because the issue is related to load order of mods (see the additional notes a bit below).

Reproduction steps:

  1. Set-up new/fresh instance of Factorio (version 1.1.61).

  2. Install the following mods:

    • Automatic Train Painter, version 1.1.4
    • Fluid Wagon Color Mask, version 1.1.0 (optional dependency of Automatic Train Painter)
    • Shuttle Train Refresh, version 1.1.6
  3. Change mod configuration as follows (this should provide you with 2x4 equipment grid, sufficient to insert modules from both Automatic Train Painter and Shuttle Train Refresh):

    • Automatic Train Painter, startup:
      • Enable Locomotive Equipment Grid: true
    • Shuttle Train Refresh, startup:
      • Add equipment grids: false
  4. Start a new game, and enable cheat mode in order to be able to receive items for free.

  5. Place rails and a locomotive.

  6. Insert Manual Color Module from the Automatic Train Painter mod into the locomotive equipment grid.

  7. Insert Shuttle train module from the Shuttle Train Refresh mod into the locomotive equipment grid.

Expected results:

  • In step (6), Manual Color Module equipment is accepted into the locomotive equipment grid.
  • In step (7), Shuttle train module equipment is accepted into the locomotive equipment grid.

Actual results:

  • [PASS] In step (6), Manual Color Module equipment is accepted into the locomotive equipment grid.
  • [FAIL] In step (7), Shuttle train module equipment cannot be inserted into the locomotive equipment grid.

Additional notes:

So, I've dug into the code of different mods and documentation a bit to figure out what is happening, and I think this has to do with loading order. Turns out that if I disable the Fluid Wagon Color Mask mod, everything works as expected, and both steps (6) and (7) pass. But upon enabling the Fluid Wagon Color Mask, step (7) starts to fail.

The catch is in how the mods are getting loaded in terms of their dependency chain lengths. According to documentation, mods with shorter chains get loaded first, and if two or more mods are of the same dependency chain length, they get compared using natural sort order.

So, if you install just the Automatic Train Painter and Shuttle Train Refresh mods, things work as expected - Automatic Train Painter mod gets loaded first, creates equipment grid, and then the Shuttle Train Refresh can update it to accept additional categories. But once you add the Fluid Wagon Color Mask mod, it changes the loading order - now Automatic Train Painter will get loaded first, won't create/update the train equipment grid, and Automatic Train Painter gets loaded afterwards, with its equipment grid set-up not including the category of the Shuttle train module equipment. I tested this by adding simple print statements in all three mods (loading order is Fluid Wagon Color Mask -> Shuttle Train Refresh -> Automatic Train Painter.

I had a look at the FARL code as well, since I was curious how that one works, and realised it's a bit of a luck - simply because FARL has no dependencies whatsoever, and it sorts ahead of Shuttle Train Refresh. So, if it was ever to receive a dependency, or get renamed/forked, the issue will trigger for that one as well.

The easiest fix for all this would probably be to add the Automatic Train Painter and FARL as hidden dependencies of Shuttle Train Refresh. Although, it looks to me like the only real fix (short of WUBE doing some kind of addition to the API for this) would be for modders to start depending on some standard mod that either sets-up the grid itself, or provides standard set of equipment categories (names) instead.

Best regards,
Branko

1 year, 10 months ago

So, pull request for this one would be fairly easy, but I really wanted to see if you have some better idea for this first - since it feels a bit like a hack.

1 year, 10 months ago

A pull request would be great, I am fairly busy at the moment.

I think if you add optional dependencies for ATP and Farl it should work.

1 year, 10 months ago

Ok, got the pull request going for this - thanks for providing fast feedback :)

1 year, 10 months ago

Merged, thank you for the fix!

New response