Adding fluid wagon support to Train Ore Color

Place to get help with not working mods / modding interface.
Post Reply
yeahtoast
Inserter
Inserter
Posts: 21
Joined: Wed Feb 27, 2019 6:17 pm
Contact:

Adding fluid wagon support to Train Ore Color

Post by yeahtoast »

Hello, I'm looking for help adding fluid wagon support to the (deprecated) Train Ore Color mod. Note: I am not a modder.

Currently, I have gotten the old mod working in 0.17 and have successfully added additional items into the "colors" array. Fluids, however, are not working.

The section of control.lua that reads the train contents and looks up the appropriate item color in the array is:

Code: Select all

if(train.state == defines.train_state.on_the_path and not train.manual_mode and #train.cargo_wagons > 0) then
		local total = 0
		local hit = 0
		calc = {}

		for name, count in pairs(train.get_contents()) do
			for key, color in pairs(colors) do
				if(key[name] ~= nil) then

					if(calc[key] ~= nil) then
						calc[key] = calc[key] + count
					else
						hit = hit + 1
						calc[key] = count
					end

					total = total + count
				end
			end
		end
Based on my limited knowledge of the API, this will only read cargo wagons, so I need a train.get_fluid_contents() function in here... somewhere. I will also need to change (or remove) the

Code: Select all

and #train.cargo_wagons > 0
condition. Anyone have any ideas? Any help is appreciated!

yeahtoast
Inserter
Inserter
Posts: 21
Joined: Wed Feb 27, 2019 6:17 pm
Contact:

Re: Adding fluid wagon support to Train Ore Color

Post by yeahtoast »

Huh, I actually figured it out. Just adding another for loop with train.get_contents replaced with train.get_fluid_contents, as well as adding another for loop earlier in the color processor for game.fluid_prototypes did the trick.

Post Reply

Return to “Modding help”