-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.lua
More file actions
63 lines (54 loc) · 2.62 KB
/
Copy pathcontrol.lua
File metadata and controls
63 lines (54 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local function initialize_storage()
storage.surface_temperatures = storage.surface_temperatures or {}
storage.surface_temperatures["nauvis"] = 15
storage.surface_temperatures["vulcanus"] = 800
storage.surface_temperatures["gleba"] = 20
storage.surface_temperatures["fulgora"] = 25
storage.surface_temperatures["aquilo"] = -180
storage.surface_temperatures["telemi"] = -240
storage.surface_temperatures["space-platform"] = -273
storage.loss_rates = storage.loss_rates or {}
storage.loss_rates["nauvis"] = 0.0015
storage.loss_rates["vulcanus"] = 0.012
storage.loss_rates["gleba"] = 0.0025
storage.loss_rates["fulgora"] = 0.0008
storage.loss_rates["aquilo"] = 0.01
storage.loss_rates["telemi"] = 0.0003
storage.loss_rates["space-platform"] = 0.0002
storage.gain_rates = storage.gain_rates or {}
storage.gain_rates["nauvis"] = 20
storage.gain_rates["vulcanus"] = 60
storage.gain_rates["gleba"] = 25
storage.gain_rates["fulgora"] = 1000
storage.gain_rates["aquilo"] = 4
storage.gain_rates["telemi"] = 35
storage.gain_rates["space-platform"] = 30
end
script.on_init(initialize_storage)
script.on_configuration_changed(initialize_storage)
script.on_nth_tick(15, function()
if not storage.loss_rates or not storage.surface_temperatures then
initialize_storage()
end
-- Building heating
for _, surface in pairs(game.surfaces) do
local surface_name = surface.name
local solar_multiplier = surface.solar_power_multiplier
local speed_factor = 1
local gain_rate = storage.gain_rates[surface_name] or 20
local ambient = storage.surface_temperatures[surface_name] or 15
local loss_rate = storage.loss_rates[surface_name] or 0.0025
for _, furnace in pairs(surface.find_entities_filtered{name = "solar-furnace"}) do
local heat_gain = gain_rate * solar_multiplier
local damping = 1 + speed_factor * loss_rate * 10
local new_temp = (furnace.temperature + speed_factor * (heat_gain + loss_rate * 10 * ambient)) / damping
furnace.temperature = math.min(math.max(new_temp, -273), 300000)
end
for _, sinteringmachine in pairs(surface.find_entities_filtered{name = "solar-sintering-machine"}) do
local heat_gain = gain_rate * solar_multiplier
local damping = 1 + speed_factor * loss_rate * 10
local new_temp = (sinteringmachine.temperature + speed_factor * (heat_gain + loss_rate * 10 * ambient)) / damping
sinteringmachine.temperature = math.min(math.max(new_temp, -273), 300000)
end
end
end)