Compare commits

...

10 Commits

Author SHA1 Message Date
238fcec205 Bump version 2024-07-17 23:25:30 +03:00
dfc9ae95aa Migrate towers 2024-07-17 23:25:30 +03:00
1f97804bbb Migrate reactors
Or rather, recover them from the map
2024-07-17 23:24:10 +03:00
ac9e3e27e1 Remove useless migrations 2024-07-17 23:24:10 +03:00
595b5adaa5 Fix mod name localization 2024-07-17 23:24:10 +03:00
28b0c2f8b4 Start changelog anew 2024-07-17 22:46:18 +03:00
a85652c4ba Bump version to 0.1.1 2024-07-15 00:56:56 +03:00
15e899ce5f Describe migration 2024-07-15 00:56:56 +03:00
a107061662 Remove vanilla neighbour bonus
It was causing heat overproduction too.
2024-07-15 00:56:56 +03:00
f3fa23609c Fix heat overproduction
This is not a real fix, just a work-around for now
2024-07-15 00:56:56 +03:00
9 changed files with 175 additions and 479 deletions

View File

@ -1,116 +1,13 @@
---------------------------------------------------------------------------------------------------
Version: 3.1.5
Date: 2024.04.15
Version: 0.1.1
Date: 2024.07.14
Bugfixes:
- fixed error during mod migration phase
- fixed heat overproduction due to vanilla neighbour bonus
- worked around heat overproduction due to force-setting reactor temperature
---------------------------------------------------------------------------------------------------
Version: 3.1.4
Date: 2022.05.22
Changes:
- cleaned up heat network merge algorithm code
- improved debug functions
- updated readme.md
Version: 0.1.2
Date: 2024.07.17
Bugfixes:
- fixed merging heat networks when placing reactors at chunk borders
- fixed changelog Locale wording
Locale:
- updated russian translation, big thanks to Gesugao-san
---------------------------------------------------------------------------------------------------
Version: 3.1.3
Date: 2022.04.24
Bugfixes:
- fixed sarcophagus recipe remained disabled after research
- fixed exception if cell was empty in get_entity_neighbour_cells at scripts/heat/math.lua:332
Locale:
- added korean translation, big thanks to x2605
---------------------------------------------------------------------------------------------------
Version: 3.1.2
Date: 2021.08.20
Bugfixes:
- fix settings localizations
- fix error due to missing setting name
- fix sarcophagus entity picture statement
- remove unused code
Locale:
- update english tips and tricks
- update settings descriptions
License:
- update license.txt
---------------------------------------------------------------------------------------------------
Version: 3.1.1
Date: 2021.08.17
Bugfixes:
- fix specific heat of heat buffer of reactor
---------------------------------------------------------------------------------------------------
Version: 3.1.0
Date: 2021.08.14
Info:
- revived meltdown explosion map setting
- atomic bombs from True-Nukes need to be enabled if alternate meltdown explosion setting is used
Features:
- meltdown explosion compatibility with True-Nukes and PlutoniumEnergy
- cooling tower lights
Changes:
- rm tint from breeder
Bugfixes:
- fix crash on surface deleted
- fix removing non-empty reactors with robots
- fix reactors running forever when burnt result is full
- fix missing mod interface script_raised_revive event
- fix heat buffer connections; hack limit of 200 using big-data-string mod
- fix mod setting namespace
- fix lighting & masking
- cleanup textures
---------------------------------------------------------------------------------------------------
Version: 3.0.0
Date: 2021.01.29
Info:
- code rewrite, cleanup
- saves with the 2.x version will be converted
- saves with the 3.x version aren't backward compatible! Test carefully.
- unlimited heat-pipe network size
- no periodic heat-pipe checks anymore
- meltdown explosion fixed to regular
- fallout mode fixed to clouds and radioactivity
- meltdown mode fixed to ruin with sarcophagus
- manual neighbor check removed due to heat-network optimizations
- periodic neighbor check removed due to heat-network optimizations
Bugfixes:
- blueprinting fixes
- bot and pipette placement fixes
- consistent event handling
- sarcophagus fits over adjacent reactor ruins
- tons of code and logic fixes
- code reorder, modularization
- heat-network rewrite, new logic with clustered A* pathfinder
- underground heat-pipe support removed, now handled through event system
- hack to get heat buffer connections from prototype
- deterministic runtime behavior
- remove rr-interface calls, except for debugging
- add readme.md
- fix tofu in changelog.txt
Locale:
- update english translation
- add german translation
- update russian translation
Graphics:
- cleanup unused files
- remove nuclear explosion
---------------------------------------------------------------------------------------------------
Version: 2.20.0
Date: 2020.12.26
Changes:
- included a few (hopefully) helpful entries in the tips and tricks
---------------------------------------------------------------------------------------------------
Version: 2.19.1
Date: 2020.12.25
Bugfixes:
- fixed error in GUI
Changes:
- reactor cannot be started / stopped from GUI anymore
---------------------------------------------------------------------------------------------------
Version: 2.19.0
Date: 2020.12.23
Info:
- compatibility with Factorio version 1.1
- BACKUP YOUR SAVEGAME BEFORE OVERWRITING IT !
- fixed reactor migration from RealisticReactors
- fixed tower migration from RealisticReactors
- fixed misapplied mod name localization

View File

@ -1,6 +1,6 @@
{
"name": "UnrealisticReactors",
"version": "0.1.0",
"version": "0.1.2",
"title": "Unrealistic Reactors",
"author": "numzero, dodo.the.last, max2344, IngoKnieto, OwnlyMe",
"description": "Add more challenging nuclear reactors with a breeder reactor and a cooling tower. The reactors have to be controlled via integrated circuit interface signals. The reactors have a dynamic heat output depending on their temperature. They need proper cooling, otherwise a nuclear meltdown will occur.",

View File

@ -1,8 +1,8 @@
[mod-name]
RealisticReactors=Unrealistic Reactors
UnrealisticReactors=Unrealistic Reactors
[mod-description]
RealisticReactors=Add more challenging nuclear reactors with a breeder reactor and a cooling tower. The reactors have to be controlled via integrated circuit interface signals. The reactors have a dynamic heat output depending on their temperature. They need proper cooling, otherwise a nuclear meltdown will occur
UnrealisticReactors=Add more challenging nuclear reactors with a breeder reactor and a cooling tower. The reactors have to be controlled via integrated circuit interface signals. The reactors have a dynamic heat output depending on their temperature. They need proper cooling, otherwise a nuclear meltdown will occur
[entity-name]
realistic-reactor-interface=Nuclear reactor circuit interface

View File

@ -1,8 +1,8 @@
[mod-name]
RealisticReactors=Нереалистичные Реакторы
UnrealisticReactors=Нереалистичные Реакторы
[mod-description]
RealisticReactors=Переосмыслите технологии ванильной ядерной энергетики, добавьте градирню, новый ядерный реактор и реактор-размножитель к игре! Нереалистичные Реакторы имеют интерфейс для взаимодействия с внутренними системами. Интерфейс позволяет автоматизацию контроля над реактором и управление динамической теплоотдачей в зависимости от температуры ядра реактора. По этой причине Реалистичные Реакторы требуют внедрения соответствующих систем охлаждения и теплообмена, в противном случае активная зона реактора расплавится и последствия будут поистине неприятными.
UnrealisticReactors=Переосмыслите технологии ванильной ядерной энергетики, добавьте градирню, новый ядерный реактор и реактор-размножитель к игре! Нереалистичные Реакторы имеют интерфейс для взаимодействия с внутренними системами. Интерфейс позволяет автоматизацию контроля над реактором и управление динамической теплоотдачей в зависимости от температуры ядра реактора. По этой причине Реалистичные Реакторы требуют внедрения соответствующих систем охлаждения и теплообмена, в противном случае активная зона реактора расплавится и последствия будут поистине неприятными.
[entity-name]
realistic-reactor-interface=Интерфейс систем реактора

View File

@ -0,0 +1,147 @@
local function get_subs(entities, matchers)
local subs = {}
for _, entity in pairs(entities) do
for name, matcher in pairs(matchers) do
local matches
if type(matcher) == "string" then
matches = entity.name == matcher
else
matches = matcher(entity.name)
end
if matches then
if subs[name] ~= nil then
error("Duplicate entity for "..name)
end
subs[name] = entity
end
end
end
for name, _ in pairs(matchers) do
if subs[name] == nil then
error("Missing entity for "..name)
end
end
return subs
end
local function Signals() return { parameters = { -- signals for interface
["core_temperature" ] = {signal=SIGNAL_CORE_TEMP, count=TEMPERATURE, index=1},
["state_stopped" ] = {signal=SIGNAL_STATE_STOPPED, count=1, index=2},
["state_starting" ] = {signal=SIGNAL_STATE_STARTING, count=0, index=3},
["state_running" ] = {signal=SIGNAL_STATE_RUNNING, count=0, index=4},
["state_scramed" ] = {signal=SIGNAL_STATE_SCRAMED, count=0, index=5},
["coolant-amount" ] = {signal=SIGNAL_COOLANT_AMOUNT, count=0, index=6},
["power-output" ] = {signal=SIGNAL_REACTOR_POWER_OUTPUT, count=0, index=7},
["uranium-fuel-cells"] = {signal=SIGNAL_URANIUM_FUEL_CELLS, count=0, index=8},
--["used-uranium-fuel-cells"] = {signal=SIGNAL_USED_URANIUM_FUEL_CELLS, count=0, index=9},
["efficiency" ] = {signal=SIGNAL_REACTOR_EFFICIENCY, count=0, index=10},
["cell-bonus" ] = {signal=SIGNAL_REACTOR_CELL_BONUS, count=0, index=11},
["electric-power" ] = {signal=SIGNAL_REACTOR_ELECTRIC_POWER, count=0, index=12},
["neighbour-bonus" ] = {signal=SIGNAL_NEIGHBOUR_BONUS, count=0, index=13},
} } end
local function find_reactors()
local reactor_max_power, reactor_max_efficiency
local formula = settings["global"]["realistic-reactors-calculate-stats-function"].value
if formula == "ingo" then
reactor_max_power = 123
reactor_max_efficiency = 200
elseif formula == "ownly" then
reactor_max_power = 250
reactor_max_efficiency = 210
else
error("formula missing")
end
local reactors = {}
for name, surface in pairs(game.surfaces) do
for _, reactor_entity in ipairs(surface.find_entities_filtered{name={REACTOR_ENTITY_NAME, BREEDER_ENTITY_NAME}}) do
local p = reactor_entity.position
local subs = get_subs(surface.find_entities({{p.x-1.5, p.y-1.5}, {p.x+1.5, p.y+1.5}}), {
entity = reactor_entity.name,
core = function(name) return string.match(name, "realistic%-reactor%-%d+") end,
interface = E2I_NAME[reactor_entity.name],
eccs = BOILER_ENTITY_NAME,
power = POWER_NAME[reactor_entity.name],
lamp = function(name) return string.match(name, "rr%-%w+%-lamp") end,
light = function(name) return string.match(name, "rr%-%w+%-light") end,
})
local reactor = {
id = subs.entity.unit_number, -- ID of the reactor (doesn't change)
core_id = subs.core.unit_number, -- ID of the core (changes when core is replaced)
core = subs.core, -- core entity
interface = subs.interface, -- interface entity
eccs = subs.eccs, -- eccs entity
power = subs.power, -- power entity
entity = subs.entity, -- displayer entity
position = subs.core.position, -- core position = reactor position
state = 0, -- reactor state
state_active_since = game.tick - TICKS_PER_UPDATE, -- state begin
neighbours = 1, -- number of connected reactors and itself
control = subs.interface.get_or_create_control_behavior(), -- control behaviour for interface signals
efficiency = 0, -- reactor efficiency
bonus_cells = {}, -- list of bonus cell amount for breeder
cooling_history = 0, -- average power loss through cooling in the last TICKS_PER_UPDATE*8 ticks
lamp = subs.lamp, --reactor lamp dummy
light = subs.light, --light dummy for the lamp
interface_warning_tick = 0, --last tick an electricity warning was displayed on the interface (for imitating the game's behaviour)
interface_warning = nil, --electricity warning dummy (interface)
cooling_warning_tick = 0, --last tick an electricity warning was displayed on the cooling
cooling_warning = nil, --electricity warning dummy (cooling)
power_usage = {starting = 0,cooling = 0, interface = 0}, --portions of the power consumption
last_states_update = game.tick - TICKS_PER_UPDATE,
fuel_last_tick = 0, -- fuel value in the core on last tick
--fluid_amount_last_tick = 0, -- fluid amount in eccs on last tick
power_output_last_tick = 0, --power output in MW on last tick (only updated in start or running phase)
last_temp_update = game.tick - TICKS_PER_UPDATE,
max_power = reactor_max_power, --dynamic maximum value for gui
max_efficiency = reactor_max_efficiency, --dynamic maximum value for gui
signals = Signals(),
}
for _, saved_signal in pairs(reactor.signals.parameters) do
local real_signal = reactor.control.parameters[saved_signal.index]
if (real_signal.signal.type ~= saved_signal.signal.type) or
(real_signal.signal.name ~= saved_signal.signal.name and saved_signal.index ~= 8) then -- 8 is fuel, it may differ
error(string.format("Can't migrate signal %d (expected %q:%q, got %q:%q)",
saved_signal.index, saved_signal.signal.type, saved_signal.signal.name, real_signal.signal.type, real_signal.signal.name))
end
saved_signal.count = real_signal.count
end
reactor.control.parameters = reactor.signals.parameters
if reactor.signals.parameters["state_stopped"].count == 1 then
reactor.state = 0
elseif reactor.signals.parameters["state_starting"].count == 1 then
reactor.state = 1
elseif reactor.signals.parameters["state_running"].count == 1 then
reactor.state = 2
elseif reactor.signals.parameters["state_scramed"].count == 1 then
reactor.state = 3
end
reactors[reactor.id] = reactor
end
end
return reactors
end
local function find_towers()
local towers = {}
for name, surface in pairs(game.surfaces) do
for _, entity in ipairs(surface.find_entities_filtered{name=TOWER_ENTITY_NAME}) do
local p = entity.position
local subs = get_subs(surface.find_entities({{p.x-1.5, p.y-1.5}, {p.x+1.5, p.y+1.5}}), {
entity = TOWER_ENTITY_NAME,
steam = STEAM_ENTITY_NAME,
})
local tower = {
id = entity.unit_number,
entity = entity,
steam = subs.steam,
}
towers[tower.id] = tower
end
end
return towers
end
global.reactors = find_reactors()
global.towers = find_towers()

View File

@ -221,7 +221,7 @@ reactor_template = {
max_health = 500,
corpse = "big-remnants",
consumption = "40MW",
neighbour_bonus = 1,
neighbour_bonus = 0,
selectable_in_game = false,
vehicle_impact_sound = {filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65},
meltdown_action = nil,
@ -349,6 +349,8 @@ reactor_normal.heat_lower_layer_picture = apply_heat_pipe_glow{
shift = REACTOR_DEFAULT_PICTURE_ATTRS.shift,
}
reactor_normal.heat_buffer.specific_heat = "1kJ"
reactor_normal.heat_buffer.max_transfer = "0.00001W"
reactor_normal.heat_buffer.heat_picture = apply_heat_pipe_glow{
filename = "__UnrealisticReactors__/graphics/entity/reactor-heated.png",
priority = "extra-high",
@ -400,12 +402,12 @@ for i=1, 250 do
temp_reactor.name = "realistic-reactor-"..i
temp_reactor.collision_mask = {"item-layer"}
temp_reactor.consumption = i.."MW"
if debug_core then
temp_reactor.selection_box = {{-1.4, -2.5}, {1.4, 1.35}}
temp_reactor.selectable_in_game = true
end
data:extend({temp_reactor})
end

View File

@ -1,4 +1,10 @@
Forked from RealisticReactors, because the current maintainers deny the very possibility of any bugs in their beautiful code.
Forked from RealisticReactors due to bugs.
#### Migration from RealisticReactors
Migration from RealisticReactors is partially supported. Reactors and cooling towers should work, however intermediate states (starting or stopping) may not work as expected.
#### Original description
We introduce a nuclear reactor, a breeder reactor and a cooling tower. The nuclear reactor type has high power output while the breeder reactor type has medium power output and produces bonus materials. The thermal energy output of both reactor types as well as fuel efficiencies are dynamic and depend on operational temperature. The reactors have to be controlled with signals through the integrated circuit interface and depend on the cooling infrastructure through the Emergency Core Cooling System (ECCS) interface. Without cooling the reactor core will finally overheat and cause a meltdown. Cooling towers are designed to cool down hot water or steam coming from the ECCS or other parts of the plant. Physical layout of the power plant also plays a significant role.

View File

@ -21,8 +21,6 @@ end
local function init()
global.version = 12 -- important for migrations
global.random = game.create_random_generator()
global.lightEffects = {}

View File

@ -7,372 +7,18 @@ local splitty = require(rpath .. "gui.util").splitty
local Setting = require(rpath .. "setting")
local function on_settings_changed()
local function on_configuration_changed()
for _,reactor in pairs(global.reactors) do --updating signals for removed fuel cell mods
if reactor.entity.valid == true then
if reactor.entity.get_fuel_inventory().is_empty() then
reactor.signals.parameters["uranium-fuel-cells"].signal = {type="item", name="uranium-fuel-cell"}
reactor.signals.parameters["uranium-fuel-cells"].count = 0
reactor.signals.parameters["uranium-fuel-cells"] = {signal=SIGNAL_URANIUM_FUEL_CELLS, count=0, index=8}
end
end
reactor.signals.parameters["used-uranium-fuel-cells"] = nil
--if reactor.entity.get_burnt_result_inventory().is_empty() then
-- reactor.signals.parameters["used-uranium-fuel-cells"].signal = {type="item", name="used-up-uranium-fuel-cell"}
-- reactor.signals.parameters["used-uranium-fuel-cells"].count = 0
--end
reactor.signals.parameters["neighbour-bonus"] = {signal=SIGNAL_NEIGHBOUR_BONUS, count=0, index=13}
end
technology.init()
end
local function migration()
--msg("RealisticReactors - current mod version: "..global.version)
--game.players[1].print("on_configuration_changed. global.version: "..global.version)
if not global.version or global.version < 1 then
for i,reactor in pairs(global.reactors) do
reactor.signals.parameters["coolant-temperature"] = nil
reactor.signals.parameters["neighbour-bonus"] = nil
--fluid signal removal
--reactor.signals.parameters["coolant-amount"] = nil
if not reactor.efficiency then
reactor.efficiency = 100
end
if not reactor.signals.parameters["power-output"] then
reactor.signals.parameters["power-output"] = {signal=SIGNAL_REACTOR_POWER_OUTPUT,count=0,index=7}
end
if not reactor.signals.parameters["efficiency"] then
reactor.signals.parameters["efficiency"] = {signal=SIGNAL_REACTOR_EFFICIENCY,count=0,index=10}
end
--2
reactor.displayer = reactor.core.surface.create_entity{name = "realistic-reactor-normal", position = {reactor.core.position.x, reactor.core.position.y}, force = reactor.core.force.name, create_build_effect_smoke = false}
if not reactor.core.get_fuel_inventory().is_empty() then
reactor.displayer.get_fuel_inventory().insert(reactor.core.get_fuel_inventory()[1])
end
--3
reactor.fuel_last_tick = reactor.core.burner.remaining_burning_fuel
if reactor.core.get_fuel_inventory().is_empty() then
reactor.cells_last_tick = 0
else
reactor.cells_last_tick = reactor.core.get_fuel_inventory()[1].count
end
reactor.displayer.active = reactor.core.active
reactor.displayer.minable = reactor.core.minable
--4
reactor.power = reactor.core.surface.create_entity{
name = REACTOR_POWER_NAME,
position = reactor.core.position,
force = reactor.core.force,
create_build_effect_smoke = false,
}
reactor.power.destructible=false
reactor.power.energy = 17000000
reactor.signals.parameters["coolant-amount"] = {signal=SIGNAL_COOLANT_AMOUNT, count=0, index=6}
--5 (removed, was the old implementation of bonus cells)
--6
reactor.signals.parameters["cell-bonus"] = {signal=SIGNAL_REACTOR_CELL_BONUS, count=0, index=11}
--7
reactor.interface.operable = true
--8
reactor.cooling_history = 0
local color = "black"
if reactor.state == "starting" then
color = "yellow"
elseif reactor.state == "running" then
color = "green"
elseif reactor.state == "scramed" then
color = "red"
end
reactor.lamp = reactor.core.surface.create_entity{name = "rr-"..color.."-lamp", position = {reactor.core.position.x-0.62,reactor.core.position.y+0.6}, force = reactor.core.force.name, create_build_effect_smoke = false}
reactor.lamp.destructible = false
reactor.light = reactor.core.surface.create_entity{name = "rr-"..color.."-light", position = {reactor.core.position.x-0.62,reactor.core.position.y+0.6}, force = reactor.core.force.name, create_build_effect_smoke = false}
reactor.light.destructible = false
reactor.interface_warning_tick = 0
reactor.interface_warning = nil
reactor.cooling_warning_tick = 0
reactor.cooling_warning = nil
reactor.power_usage = {starting = 0,cooling = 0, interface = 0}
reactor.neighbours = 0
reactor.bonus_cells = {}
reactor.core.destructible = false
--9
reactor.signals.parameters["electric-power"] = {signal=SIGNAL_REACTOR_ELECTRIC_POWER, count=0, index=12}
reactor.fluid_amount_last_tick = 0
reactor.power_output_last_tick = 0
if reactor.core.get_burnt_result_inventory().is_empty() then
reactor.used_cells_last_tick = 0
else
reactor.used_cells_last_tick = reactor.core.get_burnt_result_inventory()[1].count
end
end
--7
gui.init()
--9
global.fallout = {}
global.falloutclouds = {}
global.geigers = {}
global.version=1
end
if global.version < 2 then
--10
global.ruins = {}
global.sarcophagus = {}
game.create_force("radioactivity")
game.create_force("radioactivity-strong")
--11
local reactor_state = {}
reactor_state["stopped"] = 0
reactor_state["starting"] = 1
reactor_state["running"] = 2
reactor_state["scramed"] = 3
--12
global.delayed_fallout={}
global.tick_delayer = 0
for _, stats in pairs (global.stats) do
stats.max = 999
end
for i,reactor in pairs(global.reactors) do
--11
reactor.state = reactor_state[reactor.state]
reactor.last_temp_update = game.tick
reactor.signals.parameters["uranium-fuel-cells"].signal = {type="item", name="uranium-fuel-cell"}
--reactor.signals.parameters["used-uranium-fuel-cells"].signal = {type="item", name="used-up-uranium-fuel-cell"}
reactor.signals.parameters["used-uranium-fuel-cells"] = nil
reactor.core.destructible = false
reactor.max_power = 155
reactor.interface.destructible = false
reactor.interface.minable = false
end
global.version = 2
end
if global.version <3 then
--for _, stats in pairs (global.stats) do
-- stats.max = 999
--end
global.all_heat_pipes = {}
global.underground_heat_pipes = {}
for _, surface in pairs(game.surfaces) do
global.all_heat_pipes[surface.name] = {}
local heat_pipes = surface.find_entities_filtered{type='heat-pipe'}
for _, hp in pairs (heat_pipes) do
if hp.name == "rr-underground-heat-pipe" then
table.insert(global.underground_heat_pipes, hp)
end
--function get_connected_heat_pipes(heat_pipe)
local result = {}
for i,heatpipe in pairs(heat_pipes) do
if hp.position.x == heatpipe.position.x then
if hp.position.y == heatpipe.position.y + 1 or hp.position.y == heatpipe.position.y - 1 then
----logging("--> connected to heat pipe, ID: " .. heatpipe.unit_number)
table.insert(result, heatpipe)
end
end
if hp.position.y == heatpipe.position.y then
if hp.position.x == heatpipe.position.x + 1 or hp.position.x == heatpipe.position.x - 1 then
----logging("--> connected to heat pipe, ID: " .. heatpipe.unit_number)
table.insert(result, heatpipe)
end
end
end
global.all_heat_pipes[surface.name][hp.unit_number] = {hp,result,{}}
end
end
for i,reactor in pairs(global.reactors) do
reactor.max_efficiency = 210
local hp_neighbour_entities_ew = reactor.core.surface.find_entities_filtered{area = {{reactor.position.x-2,reactor.position.y-1},{reactor.position.x+2,reactor.position.y}}, type='heat-pipe'} --east and west
local hp_neighbour_entities_n = reactor.core.surface.find_entities_filtered{area = {{reactor.position.x-1,reactor.position.y-2},{reactor.position.x+1,reactor.position.y}}, type='heat-pipe'} -- north
local table_of_heat_pipes_to_check = union_tables(hp_neighbour_entities_ew,hp_neighbour_entities_n)
for _, hp in pairs(table_of_heat_pipes_to_check) do
table.insert(global.all_heat_pipes[reactor.core.surface.name][hp.unit_number][3],reactor)
end
end
global.version = 3
end
if global.version <4 then
for i,reactor in pairs(global.reactors) do
reactor.last_states_update = game.tick
end
global.version = 4
end
if global.version <5 then
for key, gui in pairs (global.guis) do
if gui.graph then gui.graph.destroy() end
end
global.version = 5
end
if global.version <6 then
for key, force in pairs (game.forces) do
if force.technologies["nuclear-power"].researched then
force.recipes["nuclear-reactor"].enabled = true
end
end
global.version = 6
end
if global.version <7 then
for i,reactor in pairs(global.reactors) do
reactor.light.teleport{reactor.core.position.x+0.017,reactor.core.position.y+0.88}
reactor.lamp.teleport{reactor.core.position.x+0.017,reactor.core.position.y+0.88}
end
global.version = 7
end
if global.version <10 then
for i,reactor in pairs(global.reactors) do
reactor.core.get_fuel_inventory().clear()
reactor.core.get_burnt_result_inventory().clear()
reactor.core.get_fuel_inventory().insert{name="rr-dummy-fuel-cell", count = 50}
reactor.core.burner.currently_burning = "rr-dummy-fuel-cell"
reactor.core.burner.remaining_burning_fuel = 9223372035000000000
end
global.version = 10
end
if global.version <11 then
global.random = game.create_random_generator()
global.lightEffects = global.lightEffects or {}
global.interfaces = {}
network.init()
local towers = {}
global.iterate_cooling_towers = nil -- not needed anymore
for _,tower in pairs(global.towers) do
if tower.entity.valid then
towers[tower.id] = tower -- use unit_number as index
end
end
global.towers = towers
local ruins = {}
for _,ruin in pairs(global.ruins) do
if ruin.entity.valid then
ruins[ruin.id] = ruin -- use unit_number as index
ruin.entity.destructible = false
ruin.entity.minable = true
end
end
global.ruins = ruins
local fallouts = {}
for _,fallout in pairs(global.fallout) do
if fallout.surface.valid then
fallout.id = fallout.surface.index
fallout.positions = {[fallout.tick] = fallout.position}
fallout.position = nil
fallout.tick = nil
fallout.clouds = {}
fallouts[fallout.id] = fallout -- use surface.index as index
end
end
for _,cloud in pairs(global.falloutclouds) do
if cloud.valid then
local fallout = fallouts[cloud.surface.index] or {
id = cloud.surface.index,
surface = cloud.surface,
positions = {},
clouds = {},
}
fallouts[fallout.id] = fallout
table.insert(fallout.clouds, cloud)
end
end
global.falloutclouds = nil
global.fallout = fallouts
local sarcophagus = {}
for _,entity in pairs(global.sarcophagus) do
if entity.valid then
sarcophagus[entity.unit_number] = entity
end
end
global.sarcophagus = sarcophagus
local lookup = {}
for key,reactor in pairs(global.reactors) do
lookup[key] = reactor.displayer.unit_number
end
local reactors = {}
global.iterate_reactor_temp_signals = nil
global.iterate_reactor_states = nil
global.iterate_reactor_temp = nil
global.skip_temp_iteration = nil
global.tick_delayer = nil
for _,reactor in pairs(global.reactors) do
if reactor.displayer.valid then
reactor.connected_neighbours_IDs = nil
reactor.entity = reactor.displayer
reactor.displayer = nil
reactor.id = reactor.entity.unit_number
reactors[reactor.id] = reactor -- use unit_number as index
end
end
global.reactors = reactors
global.all_heat_pipes = nil
global.connected_reactors = nil
global.underground_heat_pipes = nil
local stats = {}
for key,stat in pairs(global.stats) do
stats[lookup[key]] = stat
end
global.stats = stats
local guis = {}
global.worker_key = nil
for key, gui in pairs(global.guis) do
local reactor_key, playerid = splitty(key,"-")
if gui.valid then
local id = lookup[reactor_key]
guis[id .. "-" .. playerid] = gui
gui.name = "rr_gui_" .. id
end
end
global.guis = guis
global.version = 11
end
if global.version <12 then
network.init() -- fixed a bug there, see the π release
global.version = 12
end
--msg("RealisticReactors - current mod version (after migration): "..global.version)
end
local function on_configuration_changed()
migration()
on_settings_changed()
end
return on_configuration_changed -- exports