Compare commits

..

No commits in common. "92c156fbfba3bcfee03888a880b4c60275e813cb" and "238fcec205b1a0f58b93494ac866e57675137bfb" have entirely different histories.

11 changed files with 183 additions and 31 deletions

View File

@ -1,18 +1,13 @@
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 0.1.1 Version: 0.1.1
Date: 2024-07-14 Date: 2024.07.14
Bugfixes: Bugfixes:
- fixed heat overproduction due to vanilla neighbour bonus - fixed heat overproduction due to vanilla neighbour bonus
- worked around heat overproduction due to force-setting reactor temperature - worked around heat overproduction due to force-setting reactor temperature
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 0.1.2 Version: 0.1.2
Date: 2024-07-17 Date: 2024.07.17
Bugfixes: Bugfixes:
- fixed reactor migration from RealisticReactors - fixed reactor migration from RealisticReactors
- fixed tower migration from RealisticReactors - fixed tower migration from RealisticReactors
- fixed misapplied mod name localization - fixed misapplied mod name localization
---------------------------------------------------------------------------------------------------
Version: 0.1.3
Date: UNRELEASED
Changes:
- replaced multi-entity power generation dance with direct temperature manipulation

View File

@ -1,6 +1,6 @@
{ {
"name": "UnrealisticReactors", "name": "UnrealisticReactors",
"version": "0.1.3", "version": "0.1.2",
"title": "Unrealistic Reactors", "title": "Unrealistic Reactors",
"author": "numzero, dodo.the.last, max2344, IngoKnieto, OwnlyMe", "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.", "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

@ -59,6 +59,7 @@ local function find_reactors()
local p = reactor_entity.position 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}}), { 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, entity = reactor_entity.name,
core = function(name) return string.match(name, "realistic%-reactor%-%d+") end,
interface = E2I_NAME[reactor_entity.name], interface = E2I_NAME[reactor_entity.name],
eccs = BOILER_ENTITY_NAME, eccs = BOILER_ENTITY_NAME,
power = POWER_NAME[reactor_entity.name], power = POWER_NAME[reactor_entity.name],
@ -67,11 +68,13 @@ local function find_reactors()
}) })
local reactor = { local reactor = {
id = subs.entity.unit_number, -- ID of the reactor (doesn't change) 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 interface = subs.interface, -- interface entity
eccs = subs.eccs, -- eccs entity eccs = subs.eccs, -- eccs entity
power = subs.power, -- power entity power = subs.power, -- power entity
entity = subs.entity, -- displayer entity entity = subs.entity, -- displayer entity
position = subs.entity.position, position = subs.core.position, -- core position = reactor position
state = 0, -- reactor state state = 0, -- reactor state
state_active_since = game.tick - TICKS_PER_UPDATE, -- state begin state_active_since = game.tick - TICKS_PER_UPDATE, -- state begin
neighbours = 1, -- number of connected reactors and itself neighbours = 1, -- number of connected reactors and itself

View File

@ -1,5 +0,0 @@
for _, reactor in pairs(global.reactors) do
reactor.core = nil
reactor.core_id = nil
reactor.entity.temperature = reactor.signals.parameters.core_temperature
end

View File

@ -20,3 +20,7 @@ end
insert_categories(data.raw.reactor["realistic-reactor"]) insert_categories(data.raw.reactor["realistic-reactor"])
insert_categories(data.raw.reactor["realistic-reactor-normal"]) insert_categories(data.raw.reactor["realistic-reactor-normal"])
insert_categories(data.raw.reactor["realistic-reactor-breeder"]) insert_categories(data.raw.reactor["realistic-reactor-breeder"])
for i=1, 250 do
insert_categories(data.raw.reactor["realistic-reactor-"..i])
end

View File

@ -220,7 +220,7 @@ reactor_template = {
flags = {"not-deconstructable", unpack(REACTOR_TEMPLATE_ENTITY_FLAGS)}, flags = {"not-deconstructable", unpack(REACTOR_TEMPLATE_ENTITY_FLAGS)},
max_health = 500, max_health = 500,
corpse = "big-remnants", corpse = "big-remnants",
consumption = "0.00001W", consumption = "40MW",
neighbour_bonus = 0, neighbour_bonus = 0,
selectable_in_game = false, selectable_in_game = false,
vehicle_impact_sound = {filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65}, vehicle_impact_sound = {filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65},
@ -293,6 +293,7 @@ reactor_normal.flags = {"not-rotatable", "hide-alt-info", unpack(REACTOR_ENTITY_
reactor_normal.placeable_by = {item="realistic-reactor", count = 1} reactor_normal.placeable_by = {item="realistic-reactor", count = 1}
reactor_normal.resistances = REACTOR_RESISTANCES_ATTRS reactor_normal.resistances = REACTOR_RESISTANCES_ATTRS
reactor_normal.minable = {mining_time = 1.5, result = "realistic-reactor"} reactor_normal.minable = {mining_time = 1.5, result = "realistic-reactor"}
reactor_normal.consumption = "0.00001W"
reactor_normal.collision_box = {{-1.3, -1.3}, {1.3, 1.4}} reactor_normal.collision_box = {{-1.3, -1.3}, {1.3, 1.4}}
--reactor_normal.selection_box = {{-1.4, -1.9}, {1.4, 0.5}} --reactor_normal.selection_box = {{-1.4, -1.9}, {1.4, 0.5}}
reactor_normal.selection_box = {{-1.4, -1.8}, {1.4, 1.35}} --eccs would not be selectable, but interface would. reactor_normal.selection_box = {{-1.4, -1.8}, {1.4, 1.35}} --eccs would not be selectable, but interface would.
@ -348,6 +349,8 @@ reactor_normal.heat_lower_layer_picture = apply_heat_pipe_glow{
shift = REACTOR_DEFAULT_PICTURE_ATTRS.shift, 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{ reactor_normal.heat_buffer.heat_picture = apply_heat_pipe_glow{
filename = "__UnrealisticReactors__/graphics/entity/reactor-heated.png", filename = "__UnrealisticReactors__/graphics/entity/reactor-heated.png",
priority = "extra-high", priority = "extra-high",
@ -392,6 +395,23 @@ reactor_default.resistances = {}
table.insert(reactor_template.flags, "no-automated-item-insertion") table.insert(reactor_template.flags, "no-automated-item-insertion")
table.insert(reactor_template.flags, "no-automated-item-removal") table.insert(reactor_template.flags, "no-automated-item-removal")
-- Nuclear reactor x, running phase
for i=1, 250 do
local temp_reactor = table.deepcopy(reactor_template)
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
-- Circuit interface entity for nuclear reactor -- Circuit interface entity for nuclear reactor
reactor_interface = { reactor_interface = {
type = "constant-combinator", type = "constant-combinator",

View File

@ -90,4 +90,20 @@ data:extend{
place_result = "realistic-breeder-interface", place_result = "realistic-breeder-interface",
stack_size = 50, stack_size = 50,
}, },
-- Dummy Fuel Cell for Reactor Core
{
type = "item",
name = "rr-dummy-fuel-cell",
flags = {"hidden","hide-from-bonus-gui","hide-from-fuel-tooltip"},
icon = "__base__/graphics/icons/uranium-fuel-cell.png",
icon_size = 32,
subgroup = "intermediate-product",
order = "r[uranium-processing]-a[uranium-fuel-cell]",
fuel_category = "nuclear",
burnt_result = "used-up-uranium-fuel-cell",
fuel_value = "9223372035GJ",
stack_size = 50,
},
} }

View File

@ -32,7 +32,13 @@ local function Signals() return { parameters = { -- signals for interface
local function add_reactor(entity,interface) local function add_reactor(entity,interface)
local surface = entity.surface local surface = entity.surface
local p,f = entity.position,entity.force local p,f = entity.position,entity.force
local reactor_core = surface.create_entity{
name = "realistic-reactor-1",
position = p,
force = f,
}
--reactor is actually the reactor core --reactor is actually the reactor core
reactor_core.destructible = false
--logging("---------------------------------------------------------------") --logging("---------------------------------------------------------------")
--logging("Adding new reactor: "..entity.name) --logging("Adding new reactor: "..entity.name)
--logging("Reactor core ID: " .. reactor_core.unit_number) --logging("Reactor core ID: " .. reactor_core.unit_number)
@ -74,6 +80,9 @@ local function add_reactor(entity,interface)
reactor_lamp.destructible = false reactor_lamp.destructible = false
reactor_light.destructible = false reactor_light.destructible = false
-- reactor is not active when it is build (state=stopped)
reactor_core.active = false
--max power for gui --max power for gui
if Setting.ingos_formula() then if Setting.ingos_formula() then
reactor_max_power = 123 reactor_max_power = 123
@ -86,11 +95,13 @@ local function add_reactor(entity,interface)
end end
local reactor = { local reactor = {
id = entity.unit_number, -- ID of the reactor (doesn't change) id = entity.unit_number, -- ID of the reactor (doesn't change)
core_id = reactor_core.unit_number, -- ID of the core (changes when core is replaced)
core = reactor_core, -- core entity
interface = interface, -- interface entity interface = interface, -- interface entity
eccs = eccs, -- eccs entity eccs = eccs, -- eccs entity
power = power, -- power entity power = power, -- power entity
entity = entity, -- displayer entity entity = entity, -- displayer entity
position = entity.position, -- core position = reactor position position = reactor_core.position, -- core position = reactor position
state = 0, -- reactor state state = 0, -- reactor state
state_active_since = game.tick, -- state begin state_active_since = game.tick, -- state begin
neighbours = 1, -- number of connected reactors and itself neighbours = 1, -- number of connected reactors and itself
@ -115,6 +126,7 @@ local function add_reactor(entity,interface)
signals = Signals(), signals = Signals(),
} }
global.reactors[reactor.id] = reactor global.reactors[reactor.id] = reactor
reactor.core.get_fuel_inventory().insert{name="rr-dummy-fuel-cell", count = 50}
reactor.control.parameters = reactor.signals.parameters reactor.control.parameters = reactor.signals.parameters
--logging("-> reactor successfully added") --logging("-> reactor successfully added")
--logging("") --logging("")
@ -180,6 +192,7 @@ local function remove_reactor(entity, tick, has_died)
--remove other stuff --remove other stuff
if reactor.power.valid then reactor.power.destroy() end -- remove power entity if reactor.power.valid then reactor.power.destroy() end -- remove power entity
if reactor.eccs.valid then reactor.eccs.destroy() end -- remove eccs if reactor.eccs.valid then reactor.eccs.destroy() end -- remove eccs
if reactor.core.valid then reactor.core.destroy() end
if reactor.lamp.valid then reactor.lamp.destroy() end if reactor.lamp.valid then reactor.lamp.destroy() end
if reactor.light.valid then reactor.light.destroy() end if reactor.light.valid then reactor.light.destroy() end
if reactor.interface_warning and reactor.interface_warning.valid then reactor.interface_warning.destroy() end if reactor.interface_warning and reactor.interface_warning.valid then reactor.interface_warning.destroy() end
@ -190,6 +203,72 @@ local function remove_reactor(entity, tick, has_died)
end end
-- replaces the reactor core entity with another one
local function replace_reactor_core(reactor, new_reactor_entity_name)
local temp = reactor.core.temperature
--logging("Building reactor model: "..new_reactor_entity_name)
--logging("- old reactor ID: " .. reactor.id)
--logging("- old reactor core ID: " .. reactor.core_id)
-- create new reactor core
local new_reactor_core = reactor.core.surface.create_entity{
name = new_reactor_entity_name,
position = reactor.core.position,
force = reactor.core.force,
create_build_effect_smoke = false,
}
--logging("- new reactor core ID: " .. new_reactor_core.unit_number)
-- copy everything from old core to new core
new_reactor_core.copy_settings(reactor.core) --(what is this actually copying???) -- on/off state for example
new_reactor_core.temperature = temp
new_reactor_core.destructible = false
--logging("-> updated temperature: " .. new_reactor_core.temperature)
-- transfer burner heat and remaining fuel in burner
--if reactor.state == 0 and not (Setting.behavior("scram") == "stop-half-empty") then
-- -- do nothing (don't transfer burner heat to a stopped or scramed reactor)
-- if Setting.behavior("scram") == "consume-additional-cell" and reactor.entity.burner.currently_burning then
-- reactor.entity.get_burnt_result_inventory().insert({name = reactor.entity.burner.currently_burning.burnt_result.name, count = 1})
-- reactor.entity.burner.currently_burning = nil
-- end
--
-- --logging("-> burner settings not transferred, state: stopped or scramed")
--else
-- -- transfer current burner settings
-- --if reactor.core.burner.heat > 0 then --not reliable!
-- if reactor.entity.burner.remaining_burning_fuel > 0 then
--new_reactor_core.burner.currently_burning = game.item_prototypes["uranium-fuel-cell"]
--new_reactor_core.burner.currently_burning = reactor.entity.burner.currently_burning
new_reactor_core.burner.currently_burning = "rr-dummy-fuel-cell"
new_reactor_core.burner.remaining_burning_fuel = 9223372035000000000
new_reactor_core.burner.heat = reactor.entity.burner.heat
--logging("-> updated burner heat: " .. new_reactor_core.burner.heat)
--new_reactor_core.burner.remaining_burning_fuel = reactor.entity.burner.remaining_burning_fuel
--logging("-> updated burner remaining_burning_fuel: " .. new_reactor_core.burner.remaining_burning_fuel)
-- else
-- --logging("-> burner settings not transferred, empty")
-- end
--end
new_reactor_core.minable = false -- core should be unminable in any case cause its removed via script
new_reactor_core.get_fuel_inventory().insert{name="rr-dummy-fuel-cell", count = 50}
-- destroy old core
reactor.core.destroy()
-- store new core
reactor.core = new_reactor_core
--update reactor core id with new core unit_number
reactor.core_id = new_reactor_core.unit_number
--logging("-> reactor replaced")
--logging("- new reactor ID: " .. reactor.id)
--logging("- new reactor core ID: " .. reactor.core_id)
end
local function update_reactor_signals(reactor, tick) local function update_reactor_signals(reactor, tick)
local inventory = reactor.entity.get_fuel_inventory() local inventory = reactor.entity.get_fuel_inventory()
local cells = reactor.signals.parameters["uranium-fuel-cells"] local cells = reactor.signals.parameters["uranium-fuel-cells"]
@ -204,7 +283,7 @@ local function update_reactor_signals(reactor, tick)
if game.tick - reactor.interface_warning_tick >=60 and reactor.interface_warning and reactor.interface_warning.valid then if game.tick - reactor.interface_warning_tick >=60 and reactor.interface_warning and reactor.interface_warning.valid then
reactor.interface_warning.destroy() reactor.interface_warning.destroy()
end end
reactor.signals.parameters["core_temperature"].count = reactor.entity.temperature reactor.signals.parameters["core_temperature"].count = reactor.core.temperature
local fluid = reactor.eccs.fluidbox[1] local fluid = reactor.eccs.fluidbox[1]
if fluid then if fluid then
@ -241,7 +320,7 @@ local function update_reactor_temperature(reactor, tick)
local time_passed = math.max(1,tick - reactor.last_temp_update) local time_passed = math.max(1,tick - reactor.last_temp_update)
reactor.last_temp_update = tick reactor.last_temp_update = tick
local change_mult = CHANGE_MULTIPLIER * (time_passed / 15) local change_mult = CHANGE_MULTIPLIER * (time_passed / 15)
local reactor_core_temperature = reactor.entity.temperature local reactor_core_temperature = reactor.core.temperature
local reactor_state = reactor.state local reactor_state = reactor.state
local powersignal = reactor.signals.parameters["power-output"].count local powersignal = reactor.signals.parameters["power-output"].count
local reactor_efficiency = reactor.efficiency local reactor_efficiency = reactor.efficiency
@ -283,10 +362,10 @@ local function update_reactor_temperature(reactor, tick)
local Tchange_reactor_env = (Tdelta_reactor_env * change_mult * 0.1) local Tchange_reactor_env = (Tdelta_reactor_env * change_mult * 0.1)
--logging("-> Tchange_reactor_env: " .. Tchange_reactor_env) --logging("-> Tchange_reactor_env: " .. Tchange_reactor_env)
if (reactor_core_temperature - Tchange_reactor_env) > 15 then if (reactor_core_temperature - Tchange_reactor_env) > 15 then
reactor.entity.temperature = reactor_core_temperature - Tchange_reactor_env reactor.core.temperature = reactor_core_temperature - Tchange_reactor_env
reactor_core_temperature = reactor_core_temperature - Tchange_reactor_env reactor_core_temperature = reactor_core_temperature - Tchange_reactor_env
else else
reactor.entity.temperature = 15 reactor.core.temperature = 15
reactor_core_temperature = 15 reactor_core_temperature = 15
end end
]] ]]
@ -301,8 +380,8 @@ local function update_reactor_temperature(reactor, tick)
end end
end end
-- generate power -- do decay heat effect if state is scramed
if reactor_state ~= 0 then if reactor_state == 3 and Setting.behavior("scram") == "decay-heat-v1" then
reactor_core_temperature = reactor_core_temperature + powersignal/20 reactor_core_temperature = reactor_core_temperature + powersignal/20
end end
@ -456,7 +535,7 @@ local function update_reactor_temperature(reactor, tick)
-- destroy the reactor core (will trigger meltdown) -- destroy the reactor core (will trigger meltdown)
reactor.entity.die() reactor.entity.die()
else else
reactor.entity.temperature = reactor_core_temperature reactor.core.temperature = reactor_core_temperature
end end
end end
@ -477,7 +556,9 @@ local function change_reactor_state(new_state, reactor, tick)
reactor.signals.parameters["state_running"].count = 0 reactor.signals.parameters["state_running"].count = 0
reactor.signals.parameters["state_scramed"].count = 0 reactor.signals.parameters["state_scramed"].count = 0
-- configure reactor -- configure reactor
replace_reactor_core(reactor,"realistic-reactor-1")
reactor.entity.active = false reactor.entity.active = false
reactor.core.active = false
reactor.entity.minable = true reactor.entity.minable = true
elseif new_state == 1 then elseif new_state == 1 then
--set signals --set signals
@ -487,6 +568,7 @@ local function change_reactor_state(new_state, reactor, tick)
reactor.signals.parameters["state_scramed"].count = 0 reactor.signals.parameters["state_scramed"].count = 0
-- configure reactor -- configure reactor
reactor.entity.active = true reactor.entity.active = true
reactor.core.active = true
--reactor.debug_start_cell = true --reactor.debug_start_cell = true
reactor.entity.minable = false reactor.entity.minable = false
light_color = "yellow" light_color = "yellow"
@ -498,6 +580,7 @@ local function change_reactor_state(new_state, reactor, tick)
reactor.signals.parameters["state_scramed"].count = 0 reactor.signals.parameters["state_scramed"].count = 0
-- configure reactor -- configure reactor
reactor.entity.active = true reactor.entity.active = true
reactor.core.active = true
reactor.entity.minable = false reactor.entity.minable = false
light_color = "green" light_color = "green"
@ -509,6 +592,7 @@ local function change_reactor_state(new_state, reactor, tick)
reactor.signals.parameters["state_scramed"].count = 1 reactor.signals.parameters["state_scramed"].count = 1
-- configure reactor -- configure reactor
if Setting.behavior("scram") == "decay-heat-v1" then if Setting.behavior("scram") == "decay-heat-v1" then
reactor.core.active = false
reactor.entity.active = false reactor.entity.active = false
if reactor.entity.burner.currently_burning then if reactor.entity.burner.currently_burning then
reactor.entity.get_burnt_result_inventory().insert({name = reactor.entity.burner.currently_burning.burnt_result.name, count = 1}) reactor.entity.get_burnt_result_inventory().insert({name = reactor.entity.burner.currently_burning.burnt_result.name, count = 1})
@ -516,21 +600,22 @@ local function change_reactor_state(new_state, reactor, tick)
reactor.entity.burner.currently_burning = nil reactor.entity.burner.currently_burning = nil
reactor.entity.burner.remaining_burning_fuel = 0 reactor.entity.burner.remaining_burning_fuel = 0
else else
reactor.core.active = true
reactor.entity.active = true reactor.entity.active = true
end end
reactor.entity.minable = false reactor.entity.minable = false
light_color = "red" light_color = "red"
end end
local p = reactor.position local p = reactor.core.position
reactor.lamp = reactor.entity.surface.create_entity{ reactor.lamp = reactor.core.surface.create_entity{
name = "rr-"..light_color.."-lamp", name = "rr-"..light_color.."-lamp",
position = {p.x+0.017,p.y+0.88}, position = {p.x+0.017,p.y+0.88},
force = reactor.entity.force.name, force = reactor.core.force.name,
} }
reactor.light = reactor.entity.surface.create_entity{ reactor.light = reactor.core.surface.create_entity{
name = "rr-"..light_color.."-light", name = "rr-"..light_color.."-light",
position = {p.x+0.017,p.y+0.88}, position = {p.x+0.017,p.y+0.88},
force = reactor.entity.force.name, force = reactor.core.force.name,
} }
reactor.lamp.destructible = false reactor.lamp.destructible = false
reactor.light.destructible = false reactor.light.destructible = false
@ -540,7 +625,9 @@ end
local function update_reactor_states(reactor, tick) local function update_reactor_states(reactor, tick)
--logging("---") --logging("---")
--logging("Updating reactor ID: " .. reactor.id) --logging("Updating reactor ID: " .. reactor.id)
--logging("Reactor core ID: " .. reactor.core_id)
--logging("Reactor type: ".. reactor.entity.name) --logging("Reactor type: ".. reactor.entity.name)
--logging("Reactor model: " .. reactor.core.name)
--logging("Reactor state: " .. reactor.state) --logging("Reactor state: " .. reactor.state)
local running_time = math.ceil((tick - reactor.state_active_since)/60) local running_time = math.ceil((tick - reactor.state_active_since)/60)
--logging("-> state active for (s): " .. running_time) --logging("-> state active for (s): " .. running_time)
@ -698,7 +785,7 @@ local function update_reactor_states(reactor, tick)
-- reactor_parameters.bonus_cells = 0 -- reactor_parameters.bonus_cells = 0
-- end -- end
--logging("-> Temperature="..reactor.entity.temperature.." PowerOutput="..reactor_parameters.power.." Efficiency="..math.floor(reactor_parameters.efficiency).." BonusCellAmount: "..reactor_parameters.bonus_cells) --logging("-> Temperature="..reactor.core.temperature.." PowerOutput="..reactor_parameters.power.." Efficiency="..math.floor(reactor_parameters.efficiency).." BonusCellAmount: "..reactor_parameters.bonus_cells)
--apply material bonus by adding empty fuel cell --apply material bonus by adding empty fuel cell
local burnt_result local burnt_result
@ -778,16 +865,37 @@ local function update_reactor_states(reactor, tick)
if reactor_state == 2 or reactor_state == 1 then if reactor_state == 2 or reactor_state == 1 then
reactor.power_output_last_tick = reactor_parameters.power reactor.power_output_last_tick = reactor_parameters.power
end end
-- replace reactor with updated level version
--logging("Replace reactor model:")
local reactor_to_build = "realistic-reactor-" .. math.max(1,reactor_parameters.power)
--logging("-Reactor to be: "..reactor_to_build)
--logging("-Current reactor: "..reactor.core.name)
if reactor.core.name == reactor_to_build then
--logging("-> Reactor already build.")
elseif not (reactor_state == 3 and Setting.behavior("scram") == "decay-heat-v1") then
replace_reactor_core(reactor,reactor_to_build)
end
end end
-- UPDATE DISPLAYER -- -- UPDATE DISPLAYER --
reactor.entity.temperature = reactor.core.temperature
reactor.last_states_update = game.tick reactor.last_states_update = game.tick
end end
local function is_core(entity)
return string.sub(entity.name, 1, 18) == "realistic-reactor-"
and not E2I_NAME[entity.name]
end
local function is_reactor(entity) local function is_reactor(entity)
return entity.type == "reactor" return entity.type == "reactor"
and not is_core(entity)
end end
local function reactor_is_empty(entity) local function reactor_is_empty(entity)

View File

@ -20,6 +20,13 @@ local function find_nuclear_ghost(surface, position, name)
})[1] })[1]
end end
local function get_reactor_core_power(entity)
if string.sub(entity.name,1,18) ~= "realistic-reactor-" then return nil end
return tonumber(string.sub(entity.name, 19))
end
local function create_warning(entity,kind) local function create_warning(entity,kind)
local warning = entity.surface.create_entity{ local warning = entity.surface.create_entity{
name = "rr-" .. kind .. "-warning", name = "rr-" .. kind .. "-warning",
@ -45,6 +52,7 @@ end
return { -- exports return { -- exports
create_steam = create_steam, create_steam = create_steam,
create_warning = create_warning, create_warning = create_warning,
get_reactor_core_power = get_reactor_core_power,
next_delay = next_delay, next_delay = next_delay,
find_nuclear_entity = find_nuclear_entity, find_nuclear_entity = find_nuclear_entity,
find_nuclear_ghost = find_nuclear_ghost, find_nuclear_ghost = find_nuclear_ghost,

View File

@ -4,7 +4,7 @@ local Setting = require(rpath .. "setting")
-- calculate power output, efficiency, bonus cell production -- calculate power output, efficiency, bonus cell production
local function calculate_stats_ingo(reactor,state_running_time) local function calculate_stats_ingo(reactor,state_running_time)
local temperature = reactor.entity.temperature local temperature = reactor.core.temperature
local reactor_neighbours = math.min(reactor.neighbours,4) local reactor_neighbours = math.min(reactor.neighbours,4)
local power local power
local power_breeder local power_breeder
@ -187,7 +187,7 @@ local function calculate_stats_ownly(reactor,running_time)
if fuel_cell ~= nil then if fuel_cell ~= nil then
fuel_cell_name = fuel_cell.name fuel_cell_name = fuel_cell.name
end end
local temperature = reactor.entity.temperature local temperature = reactor.core.temperature
local neighbours = reactor.neighbours local neighbours = reactor.neighbours
local reactors = neighbours local reactors = neighbours
reactors = math.min(4,reactors) reactors = math.min(4,reactors)

View File

@ -1,5 +1,6 @@
local rpath = (...):match("(.-)[^%.]+$") local rpath = (...):match("(.-)[^%.]+$")
local rroot = rpath:match("^([^%.]+%.)") local rroot = rpath:match("^([^%.]+%.)")
local get_reactor_core_power = require(rroot .. "entity.util").get_reactor_core_power
local mod = require(rpath .. "init") local mod = require(rpath .. "init")
local heat_buffer_transition_position = require(rpath .. "buffer").heat_buffer_transition_position local heat_buffer_transition_position = require(rpath .. "buffer").heat_buffer_transition_position
local heat_buffer_transitions = require(rpath .. "buffer").heat_buffer_transitions local heat_buffer_transitions = require(rpath .. "buffer").heat_buffer_transitions
@ -548,6 +549,7 @@ local function calculate_corner_index(area, x,y)
return i -- {1=(x,y inside area), 2=(x outside area), 3=(y outside area), 4=(x,y outside area)} return i -- {1=(x,y inside area), 2=(x outside area), 3=(y outside area), 4=(x,y outside area)}
end end
local function add_reactor_to_network(entity) local function add_reactor_to_network(entity)
if get_reactor_core_power(entity) then return end -- ignore reactor cores
local x,y,z = Coordinates(entity) local x,y,z = Coordinates(entity)
-- log(string.format("add reactor to network x=%s y=%s z=%s", x,y,z)) -- log(string.format("add reactor to network x=%s y=%s z=%s", x,y,z))
local cell = add_entity_to_network_cell(x,y,z,entity) local cell = add_entity_to_network_cell(x,y,z,entity)
@ -578,6 +580,7 @@ end
local function remove_reactor_from_network(entity) local function remove_reactor_from_network(entity)
if get_reactor_core_power(entity) then return end -- ignore reactor cores
local x,y,z = Coordinates(entity) local x,y,z = Coordinates(entity)
local cell = get_heat_network_cell(x,y,z) local cell = get_heat_network_cell(x,y,z)
local reactor = cell and cell.reactors[entity.unit_number] local reactor = cell and cell.reactors[entity.unit_number]