Document behavior of get_fluid() and set_fluid() for Fluid Wagons

robot256
Smart Inserter
Smart Inserter
Posts: 1261
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by robot256 »

It would be helpful to note that

Code: Select all

fluid_wagon.get_fluid(1)
returns the contents of the wagon, including temperature. I did not expect this work because #fluid_wagon.fluidbox == 0. Also that

Code: Select all

fluid_wagon.set_fluid(1,fluid)
works the same way. There is no defines entry for "fluid storage index" indicating what to use to get the fluid wagon or fluid turret contents.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
User avatar
Osmo
Fast Inserter
Fast Inserter
Posts: 137
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by Osmo »

It is documented on https://lua-api.factorio.com/latest/cla ... uids_count which get_fluid indirectly links to, but that's not very noticeable
robot256
Smart Inserter
Smart Inserter
Posts: 1261
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by robot256 »

Osmo wrote: Tue Sep 02, 2025 1:33 pm It is documented on https://lua-api.factorio.com/latest/cla ... uids_count which get_fluid indirectly links to, but that's not very noticeable
I didn't see that connection at all because I thought fluids_count was the total size of the fluid storage in the entity, not the number fluid containers in it that can be indexed by get_fluid. This connection definitely needs to be documented in get_fluid and set_fluid for the limits of the 'index' parameter, especially since they are far apart in the docums listing.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
curiosity
Filter Inserter
Filter Inserter
Posts: 684
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by curiosity »

robot256 wrote: Tue Sep 02, 2025 1:55 pm This connection definitely needs to be documented in get_fluid and set_fluid for the limits of the 'index' parameter, especially since they are far apart in the docums listing.
...but it is documented. https://lua-api.factorio.com/latest/cla ... #get_fluid says explicitly what the valid range is and links to fluids_count. And the description mentions "fluid storage", which is suspicious if you expect it to just be fluidboxes.
robot256
Smart Inserter
Smart Inserter
Posts: 1261
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by robot256 »

curiosity wrote: Tue Sep 02, 2025 4:00 pm
robot256 wrote: Tue Sep 02, 2025 1:55 pm This connection definitely needs to be documented in get_fluid and set_fluid for the limits of the 'index' parameter, especially since they are far apart in the docums listing.
...but it is documented. https://lua-api.factorio.com/latest/cla ... #get_fluid says explicitly what the valid range is and links to fluids_count. And the description mentions "fluid storage", which is suspicious if you expect it to just be fluidboxes.
Thank you, apparently I can't read. The other thing that threw me off was the declaration "ged_fluid(index)" and the description "gets the i-th fluid". No, it gets the "index-th" fluid ...

Also the error message when calling get_fluid(1) on an entity with fluid_count of 0 is funny, "index must be between 1 and 0."

Here's an actual useful suggestion: In the description of "get_fluid_contents()" it says that if temperature is needed, you must use fluidbox. This should say fluidbox or get_fluid().
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
curiosity
Filter Inserter
Filter Inserter
Posts: 684
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by curiosity »

Or just not mention fluidboxes at all, since get_fluid already works with them and the indexing is the same, unlike fluidboxes.
Bilka
Factorio Staff
Factorio Staff
Posts: 3561
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Document behavior of get_fluid() and set_fluid() for Fluid Wagons

Post by Bilka »

Thanks for pointing this out, I've expanded the documentation for 2.0.67.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved Requests”