[2.0.17] fluid wagon has contents but the fluidbox is empty

Bugs that are actually features.
User avatar
hgschmie
Inserter
Inserter
Posts: 33
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[2.0.17] fluid wagon has contents but the fluidbox is empty

Post by hgschmie »

consider this fluid wagon:
Screenshot 2024-11-13 at 23.48.19.png
Screenshot 2024-11-13 at 23.48.19.png (955.77 KiB) Viewed 218 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
Screenshot 2024-11-13 at 23.49.09.png (43.97 KiB) Viewed 218 times
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2964
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.17] fluid wagon has contents but the fluidbox is empty

Post 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.
User avatar
hgschmie
Inserter
Inserter
Posts: 33
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: [2.0.17] fluid wagon has contents but the fluidbox is empty

Post 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?
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2964
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.17] fluid wagon has contents but the fluidbox is empty

Post 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.
User avatar
hgschmie
Inserter
Inserter
Posts: 33
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Re: [2.0.17] fluid wagon has contents but the fluidbox is empty

Post 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.
Post Reply

Return to “Not a bug”