Train Stop Item Color


Automatically colors train stops based on [item=...] tags in their names.

Utilities
a month ago
2.0 - 2.1
465
Trains

b Small bug.

5 days ago

This is an awesome mod and I hate I found it only today! I recently submitted a request in the forums for this fuction to be added into the base game. It got no comments so I doubt it will be taken into the game.

One issue I have notice is with the "Blend Item Colours" setting. When disabled it still does not seem to take the first icon for the color if the icon is a liquid. In my case it takes the second icon for the color, which is a storage tank. It does seem to work if the first icon is anything not a liquid icon.

Thanks again for an awesome mod!

5 days ago

Cause: The icon collection was done in two separate passes — first matching all [item=...] icons, then appending all [fluid=...] icons. This meant all item icons were always placed before all fluid icons in the list regardless of their actual order in the station name

Pretty easy fix-

In Control.lua
Replace:

-- Find all item and fluid tags
local items = {}
for item in name:gmatch("%[item=([%w%-]+)%]") do
items[#items+1] = item
end
for fluid in name:gmatch("%[fluid=([%w%-
]+)%]") do
items[#items+1] = fluid
end

With:

-- Collect item and fluid tags in the order they appear in the name
local items = {}
for tag_type, tag_name in name:gmatch("%[(%a+)=([%w%-_]+)%]") do
if tag_type == "item" or tag_type == "fluid" then
items[#items+1] = tag_name
end
end

New response