[314] local function on_tick(event)
--[[ Free Charger Reassignment (4c/s) ]]
if event.tick%15 == 0 then
if not free_chargers[counters.next_charger] then counters.next_charger = nil end
local next_charger
counters.next_charger, next_charger = next(free_chargers, counters.next_charger)
if next_charger then
if next_charger.base.valid then
if pair_charger(next_charger) then
free_chargers[next_charger.id] = nil
end
else free_chargers[next_charger.id] = nil end
end
end
--[[ Robot Recharging (25?r/10??/tick) ]]
local total_robots = constants.robots_limit
local step = math.ceil(#active_nodes/constants.nodes_interval)
local n_start = #active_nodes - ((event.tick % constants.nodes_interval) * step)
local n_stop = n_start - step + 1
for n = n_start, math.max(1, n_stop), -1 do
if total_robots <= 0 then goto end_bots end
local node = nodes[active_nodes[n]]
if node and node.active and node.cell.valid then
local beam_position = constants.have_beams and node.cell.owner.position
local surface = node.cell.owner.surface
local force = node.cell.owner.force.name
local bots = node.cell.to_charge_robots
for _, bot in pairs(bots) do
node.cost = node.cost - bot.energy
[349] bot.energy = math.huge