Filed this bug: viewtopic.php?f=7&t=67527
The GUI electricity bar oddness is not a big deal so I'm prepared for it to be not-a-bug, but from the Lua API perspective having LuaEntity .energy == .electric_buffer_size for a lamp with zero electricity available, and no internal generation capacity, is confusing.
Is there a better way than .energy > 0 to consistently detect when entities have power?
how to consistently detect when entities have electricity?
Re: how to consistently detect when entities have electricity?
I don't know if it better, but I'm using here reading in power poles:
Code: Select all
function get_total_output_energy (output_counts)
if output_counts then
local energy = 0
for input, value in pairs (output_counts) do
energy = energy + value
end
return energy
end
return false
end
Re: how to consistently detect when entities have electricity?
Try using this:
https://lua-api.factorio.com/latest/Lua ... ity.status
and
https://lua-api.factorio.com/latest/def ... ity_status
These are the statuses that show up in the tooltip now to tell you what is wrong with various machines.
https://lua-api.factorio.com/latest/Lua ... ity.status
and
https://lua-api.factorio.com/latest/def ... ity_status
These are the statuses that show up in the tooltip now to tell you what is wrong with various machines.