11local refresh_rate = 60
2+ local gui_refresh_rate = 10
23
34local types = {
45 [" storage-tank" ] = true ,
@@ -70,7 +71,9 @@ local function on_tick(event)
7071 for _ , combinator in pairs (global .combinators [event .tick % refresh_rate ]) do
7172 local count = 0
7273 if combinator .tank and combinator .tank .valid and combinator .tank .fluidbox [1 ] then
73- count = combinator .tank .fluidbox [1 ].temperature * 100
74+ local precision = 1
75+ if combinator .precise then precision = 100 end
76+ count = combinator .tank .fluidbox [1 ].temperature * precision
7477 end
7578 combinator .entity .get_or_create_control_behavior ().parameters = {
7679 enabled = true ,
@@ -83,6 +86,21 @@ local function on_tick(event)
8386 }
8487 }
8588 end
89+
90+ for i = event .tick % gui_refresh_rate + 1 , # game .players , gui_refresh_rate do
91+ local player = game .players [i ]
92+ if player .opened and player .opened .name == " fluid-temperature-combinator" then
93+ local combinator = find_in_global (player .opened )
94+ if not player .gui .left [" fluid-temperature-combinator-precise-toggle" ] then
95+ local state = true
96+ if not combinator .precise then state = false end
97+ player .gui .left .add {type = " checkbox" , name = " fluid-temperature-combinator-precise-toggle" , caption = {" precise-toggle" }, state = state }
98+ end
99+ combinator .precise = player .gui .left [" fluid-temperature-combinator-precise-toggle" ].state
100+ elseif player .gui .left [" fluid-temperature-combinator-precise-toggle" ] then
101+ player .gui .left [" fluid-temperature-combinator-precise-toggle" ].destroy ()
102+ end
103+ end
86104end
87105
88106local function on_rotated (event )
@@ -130,10 +148,18 @@ script.on_configuration_changed(function(data)
130148 global .combinators [i ] = global .combinators [i ] or {}
131149 end
132150
133- if data .mod_changes [" crafting_combinator " ] then
151+ if data .mod_changes [" fluid-temperature-combinator " ] then
134152 for _ , force in pairs (game .forces ) do
135153 if force .technologies [" circuit-network" ].researched then
136- force .recipes [" crafting-combinator" ].enabled = true
154+ force .recipes [" fluid-temperature-combinator" ].enabled = true
155+ end
156+ end
157+
158+ if data .mod_changes [" fluid-temperature-combinator" ].old_version == " 0.1.2" then
159+ for _ , tab in pairs (global .combinators ) do
160+ for i , v in pairs (tab ) do
161+ v .precise = true
162+ end
137163 end
138164 end
139165 end
0 commit comments