Thermal Solar Power


Adds the ability to build an early to mid game thermal solar complex with built-in energy storage for the night with varied features.

Content
4 years ago
0.16 - 0.18
42
Power

i Spread update across multiple ticks.

4 years ago
(updated 4 years ago)
local TICKS_PER_UPDATE = 60

do
  local unit_number = panel.unit_number
  local bucket_number = unit_number % TICKS_PER_UPDATE
  local panel_table = global.CW_Thermal_solar_panel_table
  if not panel_table then
    panel_table = {}
    global.CW_Thermal_solar_panel_table = panel_table
  end
  local bucket = panel_table[bucket_number]
  if not bucket then
    bucket = {}
    panel_table[bucket_number] = bucket
  end
  bucket[unit_number] = panel
end

do
  local panel_table = global.CW_Thermal_solar_panel_table
  if not panel_table then return end

  local bucket_number = event.tick % TICKS_PER_UPDATE
  local bucket = panel_table[bucket_number]
  if not bucket then return end

  for unit_number, panel in pairs(bucket) do
    if panel.valid then
      panel.temperature = panel.temperature + ...
    else
      bucket[unit_number] = nil
    end
  end
end

New response