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")
|
||||
|
||||
teardown = {}
|
||||
|
||||
local next = next
|
||||
|
||||
active_tick = 1
|
||||
@ -14,8 +16,6 @@ script.on_init(function()
|
||||
global.active.mining_drills = {} -- [Tick:Entity]
|
||||
global.passive = {}
|
||||
global.passive.mining_drills = {} -- [Entity:true]
|
||||
|
||||
recompute_max_mining_drill_radius()
|
||||
end)
|
||||
|
||||
script.on_load(function()
|
||||
@ -27,4 +27,8 @@ script.on_load(function()
|
||||
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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Teardown",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"title": "Teardown",
|
||||
"description": "Automate the removal of depleted miners",
|
||||
"author": "David Skrundz",
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Populate global.max_mining_drill_radius with [Category:double]
|
||||
function recompute_max_mining_drill_radius()
|
||||
-- @return [Category:double]
|
||||
function compute_max_mining_drill_radius()
|
||||
local max_radius = {}
|
||||
|
||||
local prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "mining-drill"}})
|
||||
@ -10,5 +10,5 @@ function recompute_max_mining_drill_radius()
|
||||
end
|
||||
end
|
||||
|
||||
global.max_mining_drill_radius = max_radius
|
||||
return 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 = teardown.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(teardown.max_mining_drill_radius))
|
||||
error("max_mining_drill_radius is not set for category: " .. category)
|
||||
return
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user