The reactor should last for about 398684 or 398685 seconds (aka 12 * 60 * 60 * log(600) / log(2)) which yields about 37.332 GJ of energy during the reactor's actual lifetime, which is only about 9.2 half-lives.
Re: [MOD 0.16] RITEG
Posted: Mon Sep 10, 2018 3:51 pm
by darkfrei
It's more balanced as you think. The energy in the new RITEG is 5 x 8GJexactly, also at the first moment will be exactly 600 kW output power.
The half life period will be calculated for this energy and this power so, that all maths will be always correct.
Exactly maths for new RITEG-1:
starting power: 10000*60 W
half life: 46209.812 seconds or 12,83 hours
starting energy: 40000000000 J or 40 GJ
...
[mod-setting-name]
__RITEG__autodeconstruct-is-enabled=Autodeconstruct
__RITEG__autodeconstruct-health-threshold=Threshold
[mod-setting-description]
__RITEG__autodeconstruct-is-enabled=Enable autodeconstruct the RITEG when it falls below the threshold percentage value
__RITEG__autodeconstruct-health-threshold=Threshold value in percentage for autodeconstruct. When the the RITEG health falls below the threshold it will be marked for autodeconstruct by bot. Valid values: [5,90]
@@ -1,5 +1,6 @@
-- local E = 40 -- GJ
-- local P = 600 -- kW
+local mod_name = "__RITEG__"
local ln_2 = 0.69314718
local rtg_names_list = {'RITEG-1'}
local RTG_prop =
@@ -12,11 +13,28 @@
try_init ()
update_recipes ()
add_all_rtgs_to_table ()
+ update_settings ()
end)
+-- update riteg settings
+function update_settings (event)
+ global.rtgs_settings["enabled"] = settings.global[ mod_name .. "autodeconstruct-is-enabled" ].value
+ global.rtgs_settings["threshold"] = settings.global[ mod_name .. "autodeconstruct-health-threshold" ].value
+
+ global.rtgs_settings["max_healths"] = {}
+ for i, e in pairs (rtg_names_list) do
+ global.rtgs_settings["max_healths"][e] = game.entity_prototypes[e].max_health
+ end
+end
+
+-- call update_settings when on_runtime_mod_setting_changed
+script.on_event(defines.events.on_runtime_mod_setting_changed, update_settings)
+
+
script.on_init(function(data)
try_init ()
update_recipes ()
+ update_settings ()
end)
function is_element_in_list (element, list)
@@ -80,6 +98,7 @@
if not global.rtgs then global.rtgs = {} end
if not global.tick_id then global.tick_id = 1 end
if not global.total_rtgs then global.total_rtgs = 0 end
+ if not global.rtgs_settings then global.rtgs_settings = {} end
end
script.on_event(defines.events.on_built_entity, function(event)
@@ -145,6 +164,15 @@
rtg.entity.health = math.floor(power/(50/3))
end
-- end of new code
+
+ -- autodeconstuct
+ if global.rtgs_settings["enabled"] == true then
+ local threshold_health = ( global.rtgs_settings["threshold"] * global.rtgs_settings["max_healths"][rtg.entity.name]) / 100
+ if rtg.entity.health < threshold_health then
+ rtg.entity.order_deconstruction(rtg.entity.force)
+ end
+ end
+ -- end of autodeconsturt
--printAll('RITEG [' .. global.tick_id .. '] has power ' .. rtg['power'] .. 'W and half_life = ' .. rtg['half_life'] .. 's')
global.tick_id = global.tick_id + 1
m3lk0rrr wrote: Fri Nov 02, 2018 12:35 pm
autodeconstruct draft
recommended with recursive blueprints
Thanks for your code, it was helpful.
Added new version with auto deconstruct and replacing of old RITEGs.
Re: [MOD 0.16] RITEG
Posted: Sat Mar 02, 2019 4:12 pm
by Omnifarious
Any plans to update this for 0.17?
Re: [MOD 0.16] RITEG
Posted: Sun Mar 03, 2019 10:56 am
by darkfrei
Omnifarious wrote: Sat Mar 02, 2019 4:12 pm
Any plans to update this for 0.17?
Yes, probably today.
Re: [MOD 0.17] RITEG
Posted: Sun Mar 03, 2019 3:32 pm
by darkfrei
Updated to Factorio version 0.17.
Re: [MOD 0.17] RITEG
Posted: Mon Mar 04, 2019 1:17 am
by Omnifarious
darkfrei wrote: Sun Mar 03, 2019 3:32 pm
Updated to Factorio version 0.17.
Thank you!
Re: [MOD 0.17] RITEG
Posted: Fri Jun 07, 2019 6:59 am
by aka13
darkfrei wrote: Sun Mar 03, 2019 3:32 pm
Updated to Factorio version 0.17.
Hey! I was wondering, if I am being retarded, or if you mistyped something? In the recipe for the RITEG I get a strange error -
I know that I do have the Simple Silicon mod, which alters the recipe of the t2 and t3 circuits. Do you mind helping me out finding the cause for this problem?
Re: [MOD 0.17] RITEG
Posted: Fri Jun 07, 2019 7:03 am
by darkfrei
aka13 wrote: Fri Jun 07, 2019 6:59 am
I know that I do have the Simple Silicon mod, which alters the recipe of the t2 and t3 circuits. Do you mind helping me out finding the cause for this problem?
aka13 wrote: Fri Jun 07, 2019 6:59 am
I know that I do have the Simple Silicon mod, which alters the recipe of the t2 and t3 circuits. Do you mind helping me out finding the cause for this problem?
aka13 wrote: Fri Jun 07, 2019 6:59 am
I know that I do have the Simple Silicon mod, which alters the recipe of the t2 and t3 circuits. Do you mind helping me out finding the cause for this problem?
function on_tick ()
-- multiple handlers per tick
local handlers_per_tick = handlers_per_tick_global_setting or 1
if not global.handlers then
global.handlers = {}
global.next_handler_id = 1
return
end
local id = global.next_handler_id
local n = 0
while n < handlers_per_tick do
local handler = global.handlers[id+n]
n = n + 1
if handler then
local valid = main_handler (handler) -- returns false or nil if it was something wrong
if not valid then
local max_id = #global.handlers
if id < max_id then
global.handlers[id] = global.handlers[max_id]
global.handlers[max_id] = nil
else -- id => max_id; the last one
global.handlers[id] = nil
end
end
else -- no handler, earlier was the last one
global.next_handler_id = 1
return
end
end
-- the next tick next handlers
global.next_handler_id = id + n
end
aka13 wrote: Fri Jun 07, 2019 6:59 am
I know that I do have the Simple Silicon mod, which alters the recipe of the t2 and t3 circuits. Do you mind helping me out finding the cause for this problem?