Teardown/control.lua

35 lines
848 B
Lua

fmsl = require("__fmsl__.fmsl")
local next = next
active_tick = 1
passive_tick = 31
require("teardown.mining_drill")
require("teardown.on_resource_depleted")
require("teardown.on_tick")
script.on_init(function()
storage.active = {}
storage.active.mining_drills = {} -- [Tick:Entity]
storage.passive = {}
storage.passive.mining_drills = {} -- [Entity.unit_number:Entity]
recompute_max_mining_drill_radius()
end)
script.on_load(function()
if next(storage.active.mining_drills) ~= nil then
script.on_nth_tick(active_tick, on_active_tick)
end
if next(storage.passive.mining_drills) ~= nil then
script.on_nth_tick(passive_tick, on_passive_tick)
end
end)
script.on_configuration_changed(function(data)
recompute_max_mining_drill_radius()
end)
script.on_event(defines.events.on_resource_depleted, on_resource_depleted)