Code: Select all
	if glob.dynamite~=nil then
		for i,_ in pairs(glob.dynamite) do
			glob.dynamite[i][100]=glob.dynamite[i][100]+1 --the error is here--
			if glob.dynamite[i][100]==600 then
				for pos=0,10,2.5 do
					local entities=game.findentities({{glob.dynamite[i].position.x-pos,glob.dynamite[i].position.y-pos},{glob.dynamite[i].position.x+pos,glob.dynamite[i].position.y+pos}})
					for i,_ in pairs(entities) do
						if entities[i].health~=nil then
							if entities[i].health<=50 then
								entities[i].die()
							else
								entities[i].health=entities[i].health-50
							end
						end
					end
				end
				glob.dynamite[i].destroy()
				table.remove(glob.dynamite ,i) 
			end
		end
	endalso the part where that is declared is here:
Code: Select all
	if event.createdentity.name=="dynamite" then
		if glob.dynamite==nil then
			glob.dynamite={}
			glob.dynamitecount=0
		end
		glob.dynamite[glob.dynamitecount]={}
		glob.dynamite[glob.dynamitecount]=event.createdentity
		table.insert(glob.dynamite[glob.dynamitecount], 100, 0)
		glob.dynamitecount=glob.dynamitecount+1		
	end



 (resources have an entity.amount that show how much iron/copper/etc they have). Also .damage(50,game.player.force) is probably better than .health-50 (though I had issues with the findentities also picking up further dynamite (shock wave) and the damage would destroy it, again leading to this error, so be careful of that). Or I suppose you could just wrap everything inside the for loop with if glob.dynamite.exists() else table.remove(glob.dynamite, i) end
 (resources have an entity.amount that show how much iron/copper/etc they have). Also .damage(50,game.player.force) is probably better than .health-50 (though I had issues with the findentities also picking up further dynamite (shock wave) and the damage would destroy it, again leading to this error, so be careful of that). Or I suppose you could just wrap everything inside the for loop with if glob.dynamite.exists() else table.remove(glob.dynamite, i) end