Code: Select all
if glob.alloyinserter~=nil then
for i,e in pairs(glob.alloyinserter) do
if e.entity.isvalid() then
foundryes=game.findentitiesfiltered({area = {{e.entity.position.x+2, e.entity.position.y+2}, {e.entity.position.x-2, e.entity.position.y-2}}, name="foundry"})
if foundryes[1]~=nil then
game.getplayer().print("There are more than one foundries near an alloy inserter, it wont work")
elseif foundryes[0]~=nil then
for index,data in pairs(glob.foundry) do
if data.entity.position.x==foundryes[0].position.x and data.entity.position.y==foundryes[0].position.y then
for ind,dat in pairs(e.data) do
game.getplayer().print(ind.." "..dat)
end
for ind,dat in pairs(glob.foundry.metals) do
game.getplayer().print(ind.." "..dat)
end
if tequals(e.data, glob.foundry.metals) then
e.entity.setactive(false)
end
break
end
end
else
game.getplayer().print("No foundryes have been found")
end
else
table.remove(glob.alloyinserter,i)
end
end
end