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

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

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

Post 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
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

Rseding91
Factorio Staff
Factorio Staff
Posts: 13175
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

So you want those functions on LuaFluidBox?
If you want to get ahold of me I'm almost always on Discord.

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

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

Post by LuziferSenpai »

These functions are for the fluidbox, but like I said, they select automaticly and cant be filtered.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

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

Post 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.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

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

Post 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.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

Post Reply

Return to “Modding interface requests”