Code: Select all
if glob.dynamite~=nil then
for i,_ in pairs(glob.dynamite) do
glob.dynamite[i].timer=glob.dynamite[i].timer+1
if glob.dynamite[i].entity.isvalid() and glob.dynamite[i].timer==600 then
game.createentity({name="huge-explosion",position=glob.dynamite[i].entity.position})
posi=glob.dynamite[i].entity.position
for pos=0,10,2.5 do
local entities=game.findentities({{posi.x-pos,posi.y-pos},{posi.x+pos,posi.y+pos}})
for i,_ in pairs(entities) do
if entities[i].health~=nil and entities[i].name~="dynamite" then
if entities[i].health<=50 then
entities[i].die()
else
entities[i].health=entities[i].health-50
end
elseif entities[i].name=="iron-ore" or entities[i].name=="copper-ore" or entities[i].name=="coal" or entities[i].name=="stone" then
entities[i].amount=entities[i].amount-1
game.createentity{name="item-on-ground", position=entities[i].position, stack={name=entities[i].name}}
end
end
end
glob.dynamite[i].entity.destroy()
table.remove(glob.dynamite ,i)
elseif glob.dynamite[i].entity.isvalid()==false then
table.remove(glob.dynamite, i)
elseif glob.dynamite[i].entity.isvalid() then
dyn=game.findentities({{glob.dynamite[i].entity.position.x,glob.dynamite[i].entity.position.y},{glob.dynamite[i].entity.position.x,glob.dynamite[i].entity.position.y}})
for z,_ in pairs(dyn) do
if dyn[z].health~=100000 and dyn[z].name=="dynamite" then
glob.dynamite[i].timer=570
end
end
end
end
end