mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +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:
commit
5d0adb671f
@ -7,7 +7,13 @@ local function is_depleted(drill)
|
||||
else
|
||||
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,8 +26,10 @@ 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
|
||||
if drill.name ~= "pumpjack" then
|
||||
mark_if_depleted(drill)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_resource_depleted, on_resource_depleted)
|
||||
|
Loading…
Reference in New Issue
Block a user