entity.fluidbox.get_prototype(index) should return the fluidbox prototype used by the fluidbox that can be accessed by entity.fluidbox[index]. Instead, it returns the nth entity prototype's fluidbox definition (eg, if index = 1, then it returns the first fluidbox defined in the entity prototype). However, it is still limited by the number of fluidboxes actually present in game, given by #entity.fluidbox, which for all vanilla assembler recipes, is less than the number of fluidbox prototypes.
Steps to recreate: place an assembling-machine-3, set it's recipe to fill lubricate barrel, hover over it, and execute:
/c local ent = game.player.selected
game.print(ent.fluidbox.get_prototype(1).production_type)
The string printed is "input"
Change assembler's recipe to "empty lubricant barrel" and execute the same code again.
The string printed is still "input", even though the empty barrel recipe uses the output fluidbox of the assembling-machine-3 prototype.
In both cases, "ent.fluidbox.get_prototype(2).production_type" gives an error because in "get_prototype(2)" the 2 is out of bounds as the assembler's #entity.fluidbox is 1.
What I expect to happen: "get_prototype(index)" should return the prototype used by the fluidbox referenced by "fluidbox[index]"
[Rseding91] LuaFluidBoxPrototype issues
-
- Manual Inserter
- Posts: 2
- Joined: Tue Jun 23, 2020 5:26 am
- Contact:
[1.0.0] API Bug: LuaEntityPrototype.fluid_energy_source_prototype.fluid_box has incorrect index.
Description
I am using the API to get the index of the LuaFluidBoxPrototype used as fuel input in a LuaEntityPrototype (more precisely a boiler prototype). I do it like this:
However it does not match the right fluidbox in LuaEntityPrototype.fluidbox_prototypes (index in fluid_energy_source_prototype seems to always be 1).
Example / Steps to reproduce
I am using the API to get the index of the LuaFluidBoxPrototype used as fuel input in a LuaEntityPrototype (more precisely a boiler prototype). I do it like this:
Code: Select all
local index = entity_prototype.fluid_energy_source_prototype.fluid_box.index
Example / Steps to reproduce
- Download & enable the gas-boiler mod.
- Start a new game.
- Use the following commands to read some data in fluid_energy_source_prototype
Code: Select all
/c game.print(game.entity_prototypes["gas-boiler"].fluid_energy_source_prototype.fluid_box.index) 1 /c game.print(game.entity_prototypes["gas-boiler"].fluid_energy_source_prototype.fluid_box.production_type) none
- Use the following command to dump some data about the entity's fluidboxes:
Code: Select all
/c for index,fluidbox in ipairs(game.entity_prototypes["gas-boiler"].fluidbox_prototypes) do game.print(tostring(index) .. ": " .. fluidbox.production_type) end 1: input-output 2: output 3: none
- The index returned in step 3 matches the water's input of the boiler, instead of the fuel input (which is at index 3).
Re: [1.0.0] API Bug: LuaEntityPrototype.fluid_energy_source_prototype.fluid_box has incorrect index.
I don't know if this has a nice fix. The whole mapping of runtime fluidboxes to the prototype they originated from is kind of just 'lost' because mostly the game doesn't care about it. It uses the prototype to make the fluidbox instance and then after that it mostly doesn't care about the prototype.
Mapping a runtime fluidbox back to it's prototype kind of just doesn't work.
Mapping a runtime fluidbox back to it's prototype kind of just doesn't work.
If you want to get ahold of me I'm almost always on Discord.
Re: [Rseding91] LuaFluidBoxPrototype issues
Thanks for the answer.
Personally I don't mind the issue to not be really fixed. I just want to generate a pseudo-recipe: boiler X takes fluid A as input, outputs fluids B, and uses fluid C as fuel (with possibly "any fluid" if there are no filters on the fluidbox). If you have any suggestion to retrieve that from the existing API, or just add something that allow me to do that, I'll be a happy modder.
Personally I don't mind the issue to not be really fixed. I just want to generate a pseudo-recipe: boiler X takes fluid A as input, outputs fluids B, and uses fluid C as fuel (with possibly "any fluid" if there are no filters on the fluidbox). If you have any suggestion to retrieve that from the existing API, or just add something that allow me to do that, I'll be a happy modder.
-
- Manual Inserter
- Posts: 2
- Joined: Tue Jun 23, 2020 5:26 am
- Contact:
Re: [Rseding91] LuaFluidBoxPrototype issues
Thank you for the answer.
That makes sense to not have runtime fluidboxes tied to the prototype they originated from.
Is it possible for a runtime fluidbox to have read only access to its "pipe-connections" (the array of "FluidBoxConnection") parameters? I'm not sure how the game deals with connecting fluidboxes but a fluidbox should store its possible connecting positions somewhere, right? Is it possible to make that a read only parameter for a fluidbox?
That makes sense to not have runtime fluidboxes tied to the prototype they originated from.
Is it possible for a runtime fluidbox to have read only access to its "pipe-connections" (the array of "FluidBoxConnection") parameters? I'm not sure how the game deals with connecting fluidboxes but a fluidbox should store its possible connecting positions somewhere, right? Is it possible to make that a read only parameter for a fluidbox?