1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00

Merge pull request #81 from Valansch/dev_autodecon

Fixed pumpjack deconstruction and miners not deconstructing next to w…
This commit is contained in:
Triston 2017-10-05 19:00:25 -04:00 committed by GitHub
commit 5d0adb671f

View File

@ -5,9 +5,15 @@ local function is_depleted(drill)
if drill.name == "electric-mining-drill" then
area = {{position.x - 2, position.y - 2},{position.x + 2, position.y + 2}}
else
area = {{position.x - 1, position.y - 1},{position.x + 1, position.y + 1}}
area = {{position.x - 1, position.y - 1},{position.x + 1, position.y + 1}}
end
return #drill.surface.find_entities_filtered{type="resource", area = area} == 1
local count = -1
for _,resource in pairs(drill.surface.find_entities_filtered{type="resource", area = area}) do
if resource.name ~= "crude-oil" then
count = count + 1
end
end
return count == 0
end
local function mark_if_depleted(drill)
@ -20,7 +26,9 @@ local function on_resource_depleted(event)
local area = {{event.entity.position.x-1, event.entity.position.y-1}, {event.entity.position.x+1, event.entity.position.y + 1}}
local drills = event.entity.surface.find_entities_filtered{area = area, type="mining-drill"}
for _,drill in pairs(drills) do
mark_if_depleted(drill)
if drill.name ~= "pumpjack" then
mark_if_depleted(drill)
end
end
end