From 26d3c9788e60b7fc880bec40cc3eeca085f5ae34 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Fri, 6 Dec 2024 21:09:25 +0900 Subject: [PATCH] Fixer miner circuit connections (#12) --- exp_legacy/module/modules/addons/miner.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/exp_legacy/module/modules/addons/miner.lua b/exp_legacy/module/modules/addons/miner.lua index 3b18a35f..d83a9c3f 100644 --- a/exp_legacy/module/modules/addons/miner.lua +++ b/exp_legacy/module/modules/addons/miner.lua @@ -17,6 +17,8 @@ local function drop_target(entity) if #entities > 0 then return entities[1] + else + return nil end end end @@ -27,9 +29,15 @@ local function check_entity(entity) return true end - if next(entity.circuit_connected_entities.red) ~= nil or next(entity.circuit_connected_entities.green) ~= nil then - -- connected to circuit network - return true + local egcn = entity.get_wire_connectors() + + if egcn then + for k, _ in pairs(egcn) do + if k == defines.wire_connector_id.circuit_red or k == defines.wire_connector_id.circuit_green then + -- connected to circuit network + return true + end + end end if not entity.minable then @@ -53,6 +61,10 @@ end local function chest_check(entity) local target = drop_target(entity) + if target == nil then + return + end + if check_entity(entity) then return end