Page 1 of 1
[2.0.17] fluid wagon has contents but the fluidbox is empty
Posted: Thu Nov 14, 2024 7:50 am
by hgschmie
consider this fluid wagon:
- Screenshot 2024-11-13 at 23.48.19.png (955.77 KiB) Viewed 229 times
the debugger shows that get_fluid_contents correctly returns the amount (9520 petroleum-gas) but the fluid box contains no fluids:
- Screenshot 2024-11-13 at 23.49.09.png (43.97 KiB) Viewed 229 times
Re: [2.0.17] fluid wagon has contents but the fluidbox is empty
Posted: Thu Nov 14, 2024 10:10 am
by boskid
Thanks for the report however this is not a bug. Fluid wagon is not storing its fluid inside of a fluidbox (which could have a connections in and out, ground or underground). For the same reason FluidTurret (flamethrower) may expose part of the fluid related to the FluidBox but it will not expose the internal fluid buffer through FluidBoxes API. For those cases a LuaEntity::fluids_count read, get_fluid() and set_fluid() should allow you to change them.
It is like comparing inventories to item stacks: most of the item stacks are part of inventories, but inserters have item stack that is not part of an inventory.
Re: [2.0.17] fluid wagon has contents but the fluidbox is empty
Posted: Thu Nov 14, 2024 5:49 pm
by hgschmie
Thanks for the quick answer. This seems to be a change from the 1.1 API. I am looking at the code for the Inventory Sensor (
https://github.com/0ptera/Inventory-Sen ... 2C1-L409C1) that used to work and it uses the fluidbox field to retrieve the values.
In the documentation for get_fluid_contents (
https://lua-api.factorio.com/latest/cla ... d_contents) states that "If information about fluid temperatures is required, LuaEntity::fluidbox should be used instead.". The wagon clearly has this information (it says "25˚C") but how would I retrieve it from the entity?
Re: [2.0.17] fluid wagon has contents but the fluidbox is empty
Posted: Thu Nov 14, 2024 6:06 pm
by boskid
It was changed since 1.1 because there was a pile of hacks to attempt to pretend fluid wagons contain fluid box while they did not use a fluid box, that was causing various inconsistencies when trying to obtain a fluid box prototype which was not possible to be given since wagons are not using fluid boxes.
LuaEntity::get_fluid returns Fluid which should contain temperature information. I was not checking what is the state of LuaEntity::get_fluid/set_fluid since they were implemented before fluid segments merged fluid storage was added since it vandalized quite a lot of lua api, but i think it should still keep working for fluid wagons.
Re: [2.0.17] fluid wagon has contents but the fluidbox is empty
Posted: Fri Nov 15, 2024 1:27 am
by hgschmie
Hi,
Thanks for the explanation. It seems that this is actually a documentation issue; LuaEntity::get_fluid_contents should probably refer to get_fluid/set_fluid.