Page 1 of 1

[raiguard][2.0.11] LuaEntity::get_fluid returns wrong value

Posted: Sat Oct 26, 2024 9:28 pm
by hgschmie
Consider this storage tank:
Screenshot 2024-10-26 at 14.23.55.png
Screenshot 2024-10-26 at 14.23.55.png (1.88 MiB) Viewed 519 times
Calling `get_fluid(1)` on the entity returns 26,000, not 25,000 :
Screenshot 2024-10-26 at 14.26.06.png
Screenshot 2024-10-26 at 14.26.06.png (216.51 KiB) Viewed 519 times
It seems that the call returns the contents of the pipeline, not of the storage tank.

Re: [2.0.11] LuaEntity::get_fluid returns wrong value

Posted: Tue Oct 29, 2024 7:05 pm
by przemo1232
Same thing happens when calling fluidbox methods, entity.fluidbox.get_capacity(1) for example returns the capacity of the entire pipeline.
Similarly, setting the entity.fluidbox[1] field sets the amount for the entire pipeline instead of just the entity's fluidbox

Re: [raiguard][2.0.11] LuaEntity::get_fluid returns wrong value

Posted: Thu Jan 23, 2025 9:35 pm
by raiguard
This is correct. The fluid buffer of the entity is merged with the segment, so it reports the segment values.

Re: [raiguard][2.0.11] LuaEntity::get_fluid returns wrong value

Posted: Fri Jan 24, 2025 8:16 pm
by hgschmie
Thanks for the explanation!

How does one determine how much fluid is inside an entity? It seems that any call only returns the amount in the whole fluidbox.

Re: [raiguard][2.0.11] LuaEntity::get_fluid returns wrong value

Posted: Sun Jan 26, 2025 8:06 pm
by Rseding91
Fluids are no longer owned by a given entity so what you're seeing is the actual fluid "in the entity" (all of it). If you want to know what percentage of the fluid in the merged fluid segment you can compare the total segment capacity against the capacity of the specific entity.