Update for 2.0
This commit is contained in:
parent
feaa3e7ba6
commit
eb17157d4e
|
@ -1,4 +1,9 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.0.0
|
||||
Date: 20.10.2024
|
||||
Major Features:
|
||||
- Update to 2.0
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.0.2
|
||||
Date: 20.09.2024
|
||||
Changes:
|
||||
|
|
12
control.lua
12
control.lua
|
@ -10,17 +10,17 @@ require("teardown.on_resource_depleted")
|
|||
require("teardown.on_tick")
|
||||
|
||||
script.on_init(function()
|
||||
global.active = {}
|
||||
global.active.mining_drills = {} -- [Tick:Entity]
|
||||
global.passive = {}
|
||||
global.passive.mining_drills = {} -- [Entity.unit_number:Entity]
|
||||
storage.active = {}
|
||||
storage.active.mining_drills = {} -- [Tick:Entity]
|
||||
storage.passive = {}
|
||||
storage.passive.mining_drills = {} -- [Entity.unit_number:Entity]
|
||||
end)
|
||||
|
||||
script.on_load(function()
|
||||
if next(global.active.mining_drills) ~= nil then
|
||||
if next(storage.active.mining_drills) ~= nil then
|
||||
script.on_nth_tick(active_tick, on_active_tick)
|
||||
end
|
||||
if next(global.passive.mining_drills) ~= nil then
|
||||
if next(storage.passive.mining_drills) ~= nil then
|
||||
script.on_nth_tick(passive_tick, on_passive_tick)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "Teardown",
|
||||
"version": "1.0.2",
|
||||
"version": "2.0.0",
|
||||
"title": "Teardown",
|
||||
"description": "Automate the removal of depleted miners",
|
||||
"author": "David Skrundz",
|
||||
"contact": "david@skrundz.ca",
|
||||
"homepage": "https://git.skrundz.dev/skrundztorio/Teardown",
|
||||
"factorio_version": "1.1",
|
||||
"factorio_version": "2.0",
|
||||
"dependencies": [
|
||||
"fmsl"
|
||||
]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
-- Populate global.max_mining_drill_radius with [Category:double]
|
||||
-- Populate storage.max_mining_drill_radius with [Category:double]
|
||||
function recompute_max_mining_drill_radius()
|
||||
local max_radius = {}
|
||||
|
||||
local prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "mining-drill"}})
|
||||
local prototypes = prototypes.get_entity_filtered({{filter = "type", type = "mining-drill"}})
|
||||
for _, prototype in pairs(prototypes) do
|
||||
local categories = prototype.resource_categories or {}
|
||||
for category, _ in pairs(categories) do
|
||||
|
@ -10,5 +10,5 @@ function recompute_max_mining_drill_radius()
|
|||
end
|
||||
end
|
||||
|
||||
global.max_mining_drill_radius = max_radius
|
||||
storage.max_mining_drill_radius = max_radius
|
||||
end
|
||||
|
|
|
@ -10,10 +10,10 @@ function on_resource_depleted(event)
|
|||
local position = entity.position
|
||||
|
||||
local category = entity.prototype.resource_category
|
||||
local radius = global.max_mining_drill_radius[category]
|
||||
local radius = storage.max_mining_drill_radius[category]
|
||||
|
||||
if radius == nil then
|
||||
log("max_mining_drill_radius: " .. serpent.block(global.max_mining_drill_radius))
|
||||
log("max_mining_drill_radius: " .. serpent.block(storage.max_mining_drill_radius))
|
||||
error("max_mining_drill_radius is not set for category: " .. category)
|
||||
return
|
||||
end
|
||||
|
@ -28,10 +28,10 @@ function on_resource_depleted(event)
|
|||
local target_tick = event.tick + 2
|
||||
|
||||
local add_table = false
|
||||
local active_miners = table.remove_key(global.active.mining_drills, target_tick) or {}
|
||||
local active_miners = table.remove_key(storage.active.mining_drills, target_tick) or {}
|
||||
|
||||
for _, miner in pairs(miners) do
|
||||
if miner.has_flag("hidden") then
|
||||
if miner.has_flag("not-deconstructable") then
|
||||
goto miner_continue
|
||||
end
|
||||
|
||||
|
@ -42,7 +42,7 @@ function on_resource_depleted(event)
|
|||
end
|
||||
|
||||
if add_table then
|
||||
global.active.mining_drills[target_tick] = active_miners
|
||||
storage.active.mining_drills[target_tick] = active_miners
|
||||
script.on_nth_tick(active_tick, on_active_tick)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local next = next
|
||||
|
||||
function on_active_tick(event)
|
||||
local active_mining_drills = global.active.mining_drills
|
||||
local passive_mining_drills = global.passive.mining_drills
|
||||
local active_mining_drills = storage.active.mining_drills
|
||||
local passive_mining_drills = storage.passive.mining_drills
|
||||
|
||||
local miners = table.remove_key(active_mining_drills, event.tick) or {}
|
||||
for _, miner in pairs(miners) do
|
||||
|
@ -24,7 +24,7 @@ function on_active_tick(event)
|
|||
end
|
||||
|
||||
function on_passive_tick(event)
|
||||
local passive_mining_drills = global.passive.mining_drills
|
||||
local passive_mining_drills = storage.passive.mining_drills
|
||||
|
||||
for id, miner in pairs(passive_mining_drills) do
|
||||
if miner.valid then
|
||||
|
|
Loading…
Reference in New Issue