Page 1 of 1

Return temperature with get_fluid_contents

Posted: Tue Oct 19, 2021 7:33 pm
by Honktown
It's not uncommon for a mod to use LuaEntity.get_fluid_contents() and inadvertently need to be patched later because of temperatures. I'd like to request temperature be returned as a second argument, or at least, indicate that temperatures may matter and the function "doesn't completely describe the fluid"

Re: Return temperature with get_fluid_contents

Posted: Thu Oct 21, 2021 8:46 am
by boskid
Unfortunately this interface request in current shape is a no-go. LuaEntity::get_fluid_contents does not return a per-fluidbox fluids, in some cases it is able to return amount of fluids that are not stored in a FluidBox but a regular Fluid container (FluidWagon, FluidTurret). If an entity would have 2 fluidboxes, one with steam at 165deg and second with steam at 500deg, LuaEntity::get_fluid_contents will return total amount of steam without any extra details of what those temperatures are because the temperature would have to be weighted somehow which would be useless in general when there are multiple fluid containers with same fluid inside of entity. FluidTurret has 2 fluid containers: one of a FluidBox as it behaves as a pipe, and one from internal buffer. Those 2 fluids could have a different temperature.