Skip to content

Commit 75a3576

Browse files
committed
Added precise mode toggle
Also added dependency on base
1 parent 54bc501 commit 75a3576

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
##0.1.3##
2+
+ Added a toggle for 'precise mode' - on: output is multiplied by 100; off: output remains as-is
3+
14
##0.1.2##
25
* Output is now multiplied by 100 to allow for more precision
36

control.lua

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local refresh_rate = 60
2+
local gui_refresh_rate = 10
23

34
local 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
86104
end
87105

88106
local 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

info.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "fluid-temperature-combinator",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"factorio_version": "0.14",
55
"title": "Fluid Temperature Combinator",
66
"author": "theRustyKnife",
77
"description": "A combinator that can read the temperature of fluid in an adjacent tank, boiler or pipe.",
88
"homepage": "https://mods.factorio.com/mods/theRustyKnife/fluid-temperature-combinator",
9-
"date": "26.10.2016",
10-
"dependencies": []
9+
"date": "02.11.2016",
10+
"dependencies": ["base"]
1111
}

locale/en/en.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
precise-toggle=Toggle precise mode
2+
13
[entity-description]
24
fluid-temperature-combinator=Reads the temperature of fluid in an adjacent tank
35

0 commit comments

Comments
 (0)