Checking emissions of an entity (for Worm Attack mod)
Posted: Sat Apr 02, 2016 3:08 pm
Hi I'm working on my Worm Attack mod and I want to make it so worms will prioritise structures which produce emissions. I haven't been able to work out how to do this without an error so am hoping someone could help.
This was my last attempt:
But it keeps throwing this error when it tries to check if the energy_source is nil
This was my last attempt:
Code: Select all
if targets.energy_source ~= nil then
if targets.energy_source.emissions ~= nil then
signature = signature + (targets.energy_source.emissions * 50000)
-- eg a mining drill produces 0.15/15=0.01 per tick , so it gets (100 health + 50000*0.01) = 600 signature
end
end
and I don't know how else to check whether it exists within the entity before trying to get the value.LuaEntity doesn't contain key energy_source.