[Help] LuaFluidbox does not contain key 'amount'
Posted: Sun Sep 03, 2017 11:37 pm
I'm trying to make a function that looks at the fluidbox of each pump on each tick and modifies the amount of water stored in each one. However, every time I try to access my_pump_array.fluidbox.amount I get a 'no such key' error, even when my_pump_array ~= nil returns true and my_pump_array.fluidbox ~= nil returns true.
Am I missing something about how fluidboxes work? Do I have to wait until there is some amount of fluid in the fluidbox before I can look up amount? I've tested this from so many angles and I just can't figure out why I'm getting an error.
This is the most recent test code I was using to try and figure this out.
Any help would be appreciated! Thanks!!!
Am I missing something about how fluidboxes work? Do I have to wait until there is some amount of fluid in the fluidbox before I can look up amount? I've tested this from so many angles and I just can't figure out why I'm getting an error.
This is the most recent test code I was using to try and figure this out.
local pumps = {}
pumps = game.surfaces["nauvis"].find_entities_filtered({type = "offshore-pump"})
game.players[1].print(#pumps)
for i=1,#pumps do
if pumps.fluidbox ~= nil then
game.players[1].print(pumps.fluidbox.amount)
end
end
Any help would be appreciated! Thanks!!!