Oarcinae / FactorioScenarioMultiplayerSpawn

A custom scenario for Factorio which provides each player a unique starting spawn point in a multiplayer game.
MIT License
49 stars 30 forks source link

Fix for auto decon of miners #143

Open vfinn opened 5 months ago

vfinn commented 5 months ago

This is simpler code that works with any size mining field. The key is that miner.mining_target goes to nil when the miner.mining_target.amount == 0.

function OarcAutoDeconOnTick()
    if (global.oarc_decon_miners and (#global.oarc_decon_miners > 0)) then
        for i,miner in pairs(global.oarc_decon_miners) do
            if (miner and miner.valid and (miner.mining_target == nil)) then
                miner.order_deconstruction(miner.force)
            end
            table.remove(global.oarc_decon_miners, i)
        end
    end
end

MINOR ISSUE ;)