Page 1 of 1

LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Sun Apr 05, 2020 10:32 am
by LuziferSenpai
Hey,

it would be nice if the two functions in the Title would get a fluidbox index support, because currently they detect that automaticly and that is not so good in many cases.

Here a example.

Current Code:

Code: Select all

function dsu:give_item( requested_name, requested_count )
    local fluidbox = self.entity.fluidbox
    local box = fluidbox[3]

    if not box then return 0 end

    if box.name ~= requested_name then return 0 end

    local amount = box.amount
    
    if amount <= requested_count then
        fluidbox[3] = nil
        
        return amount
    end

    box.amount = amount - requested_count
    fluidbox[3] = box

    return requested_count
end
Would get into
New potential code:

Code: Select all

function dsu:give_item( requested_name, requested_count )
    local removed_amount = self.entity.insert_fluid( { name = requested_name, amount = requested_count }, 3 )

    return removed_amount
end
The Number at the end, would be the fluidbox number (optional).

And for remove, just adding a fluidbox_index = double (optional) would do fine I would say.
For get_fluid_count, like in insert just adding another optional number for the Fluidbox Index.

Greetz,

Luzifer

Re: LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Mon Apr 20, 2020 6:12 am
by Rseding91
So you want those functions on LuaFluidBox?

Re: LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Mon Apr 20, 2020 1:01 pm
by LuziferSenpai
These functions are for the fluidbox, but like I said, they select automaticly and cant be filtered.

Re: LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Thu Apr 23, 2020 6:03 am
by LuziferSenpai
So what I just want, that this functions gets changed so it has the feature to NOT automaticly select the fluidbox, but to tell it which one to use.

Re: LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Sat Feb 06, 2021 9:14 am
by LuziferSenpai
Any update? Because this would be useful for entities, that have the fluid in the input and output of the entity. It would save alot of performance, if we can get this.

Re: LuaEntity::remove_fluid, LuaEntity::insert_fluid and LuaEntity::get_fluid_count fluidbox index support

Posted: Tue Apr 30, 2024 6:56 pm
by LuziferSenpai
Any update?