Don't save max_mining_drill_radius in global table
This commit is contained in:
parent
bf398c7ff5
commit
28f285c921
|
@ -1,5 +1,7 @@
|
||||||
fmsl = require("__fmsl__.fmsl")
|
fmsl = require("__fmsl__.fmsl")
|
||||||
|
|
||||||
|
teardown = {}
|
||||||
|
|
||||||
local next = next
|
local next = next
|
||||||
|
|
||||||
active_tick = 1
|
active_tick = 1
|
||||||
|
@ -14,8 +16,6 @@ script.on_init(function()
|
||||||
global.active.mining_drills = {} -- [Tick:Entity]
|
global.active.mining_drills = {} -- [Tick:Entity]
|
||||||
global.passive = {}
|
global.passive = {}
|
||||||
global.passive.mining_drills = {} -- [Entity:true]
|
global.passive.mining_drills = {} -- [Entity:true]
|
||||||
|
|
||||||
recompute_max_mining_drill_radius()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_load(function()
|
script.on_load(function()
|
||||||
|
@ -27,4 +27,8 @@ script.on_load(function()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
script.on_configuration_changed(function(data)
|
||||||
|
teardown.max_mining_drill_radius = compute_max_mining_drill_radius()
|
||||||
|
end)
|
||||||
|
|
||||||
script.on_event(defines.events.on_resource_depleted, on_resource_depleted)
|
script.on_event(defines.events.on_resource_depleted, on_resource_depleted)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Teardown",
|
"name": "Teardown",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"title": "Teardown",
|
"title": "Teardown",
|
||||||
"description": "Automate the removal of depleted miners",
|
"description": "Automate the removal of depleted miners",
|
||||||
"author": "David Skrundz",
|
"author": "David Skrundz",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- Populate global.max_mining_drill_radius with [Category:double]
|
-- @return [Category:double]
|
||||||
function recompute_max_mining_drill_radius()
|
function compute_max_mining_drill_radius()
|
||||||
local max_radius = {}
|
local max_radius = {}
|
||||||
|
|
||||||
local prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "mining-drill"}})
|
local prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "mining-drill"}})
|
||||||
|
@ -10,5 +10,5 @@ function recompute_max_mining_drill_radius()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
global.max_mining_drill_radius = max_radius
|
return max_radius
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,10 +10,10 @@ function on_resource_depleted(event)
|
||||||
local position = entity.position
|
local position = entity.position
|
||||||
|
|
||||||
local category = entity.prototype.resource_category
|
local category = entity.prototype.resource_category
|
||||||
local radius = global.max_mining_drill_radius[category]
|
local radius = teardown.max_mining_drill_radius[category]
|
||||||
|
|
||||||
if radius == nil then
|
if radius == nil then
|
||||||
log("max_mining_drill_radius: " .. serpent.block(global.max_mining_drill_radius))
|
log("max_mining_drill_radius: " .. serpent.block(teardown.max_mining_drill_radius))
|
||||||
error("max_mining_drill_radius is not set for category: " .. category)
|
error("max_mining_drill_radius is not set for category: " .. category)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue