LuaTrain.get_contents() for fluids

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

LuaTrain.get_contents() for fluids

Post by Optera »

Items have nice api functions like train.get_contents() and train.get_item_count(item).

Why do fluids require us to iterate over every fluidbox in every wagon?

Code: Select all

for _, wagon in pairs(train.fluid_wagons) do
  for i=1, #wagon.fluidbox do
You already do that internally to display fluids at stops and in train tooltip.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaTrain.get_contents() for fluids

Post by Rseding91 »

get_contents can't return items and fluids because the names can collide and it's a string -> count mapping.

I could add get_fluid_contents (and all the other same methods that items have but for fluids).
If you want to get ahold of me I'm almost always on Discord.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: LuaTrain.get_contents() for fluids

Post by Optera »

Rseding91 wrote:get_contents can't return items and fluids because the names can collide and it's a string -> count mapping.

I could add get_fluid_contents (and all the other same methods that items have but for fluids).
That would be just as fine.
Since I don't plan on supporting mixed trains (yet) it'd boil down to.

Code: Select all

inventory = train.get_contents() or train.get_fluid_contents()
Post Reply

Return to “Implemented mod requests”