[0.16.1]find_entities returns invalid in on_chunk_generated
Posted: Wed Dec 13, 2017 10:35 pm
In a scenario's control.lua I have
and am now getting
where line 157 is `if not ( entity.type=='player'`. It seems wrong to me that `find_entities` would return invalid entities. The code worked in 0.15. I'd be happy with a workaround, I'm just not sure what that would be.
Code: Select all
on('chunk_generated', function(ev)
for _, entity in next,ev.surface.find_entities(ev.area) or {} do
if not ( entity.type == 'player'
or keep_resources and entity.type == 'resource' ) then
entity.destroy()
end
end
--elided
end)
Code: Select all
1084.699 Error MainLoop.cpp:1010: Exception at tick 0: Error while running event level::on_chunk_generated (ID 12)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
/home/quyxkh/.factorio/temp/currently-playing/control.lua:160: in function </home/quyxkh/.factorio/temp/currently-playing/control.lua:157>