I have this snippet in control.lua:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.entity
if entity.name == "tube" or entity.name == "tube-elbow" then
if entity.fluidbox then
entity.fluidbox[1] = {name = "air", amount = 50}
end
end
end)
It seems that the whole fluid system is being given the amount of air that I assign to one tube.
It gets weirder. If I change my code to try and anticipate the amount of fluid currently in the system, say with this code:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.entity
if entity.name == "tube" or entity.name == "tube-elbow" then
local current_fluid = 0
if entity.fluidbox[1] then
game.print("entity.fluidbox[1].amount " .. entity.fluidbox[1].amount)
current_fluid = entity.fluidbox[1].amount
end
if entity.fluidbox then
local added_fluid = 50
local new_fluid_amount = current_fluid + added_fluid
entity.fluidbox[1] = {name = "air", amount = new_fluid_amount}
end
end
end)
If I could assume that every connected entity will have the same capacity, then I could hack around this, but not every air-holding entity will have 100 capacity. I am looking for some way to set a default starting amount of fluid for an entity.