Though that's effectively reverting the exploit fix that distance drops to 0, then it only checks the exact tile you're standing on (until it detects as ore, and the radius jumps up), and it also has a further issue that the distance won't decay within the safe zone at all, so once you take damage once, it's hard to stop it without a lake or a hell of a lot of mining. What I ended up using in my own saves, after I better understood what the code was trying to do, is
function flOre_is_lava()
if not settings.global["floor is lava"].value then return end
global.flOre = global.flOre or {}
for n, p in pairs(game.connected_players) do
if p.character and not global.disabled[p.surface.name] then --Spectator or admin
if math.abs(p.position.x) > global.EASY_ORE_RADIUS or math.abs(p.position.y) > global.EASY_ORE_RADIUS then
--Check for nearby ore.
local distance = global.flOre[p.name] or 1
local count = p.surface.count_entities_filtered{type="resource", area={{p.position.x-(10distance), p.position.y-(10distance)}, {p.position.x+(10distance), p.position.y+(10distance)}}}
if count > (distance * 20) ^2 * 0.80 and distance < 10 then
global.flOre[p.name] = distance + 1
else
global.flOre[p.name] = math.max(distance - 1, 1)
end
if global.flOre[p.name] > 1 then
local target = p.vehicle or p.character
p.surface.create_entity{name="acid-stream-worm-medium", target=target, source_position=target.position, position=target.position, duration=30}
target.health = target.health - 15 * distance
if target.health == 0 then target.die() end
end
else
global.flOre[p.name] = 1
end
end
end
end
Specifically, changing the damage check to > 1, adding an else to reset it in the safe area, and moving the global initialization out of the loop.