Automatic Train Painter


Automatically colors locomotives and wagons based on their contents.

Tweaks
5 days ago
0.17 - 2.0
95.8K
Trains

i UPS impact

3 years ago
(updated 3 years ago)

Hi,
would it be possible to make this mod more "light weight"? I just had a look at some portions of the code, and it looks like the program iterates over the full content of a wagon, collects the color info of each piece and then creates a color based on the average color of the content.

In 99% of all cases this approach is not needed and the wagon contains the same type of ore/equipment. So instead of calculating the average of 100, 400 or even more stacks of the same type the first one found could be used instead. This should speed up the calculations and the mod be usable in large bases.

I had to drop it cause it was eating away too much UPS (with around 200 trains, each 4 to 8 wagons and 400 slots per wagon).

3 years ago

Hello! The average color calculator actually iterates only once over each item type using the quantities from its train contents table, which is a single integer value indexed to each item. For it to run 100+ times on a single train, you'd need a train with 100+ different items. In the case of a train with just one item, the averaging calc is unnecessary and is skipped entirely -- it only seeks the color value of that one item from the color table and paints the train accordingly. That said, I will look into the calculator and painting logic to make sure it's not causing unexpected UPS impact. Admittedly it is a bit clunky in places, and this is not the first time the UPS question has been raised for megabases. For reference, do you know what your UPS usage was peaking at?

3 years ago

Hi, I will check that when I am back home in some days.

3 years ago

Back at home, here is a screen shot of the game and the mods https://i.imgur.com/Ea0ZaRL.png Train painter 0.170/0.010/6.418 which is twice the amount e.g. LTN requires.

New response