Skip to content

Commit 2ea6d3f

Browse files
committed
Added support for generators and fluid is in the ouput now
Also fixed that big entities would not be found sometimes.
1 parent 65ad6a8 commit 2ea6d3f

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##0.2.0##
2+
+ Added fluid content to output
3+
+ Added support for generators
4+
15
##0.1.3##
26
+ Added a toggle for 'precise mode' - on: output is multiplied by 100; off: output remains as-is
37

control.lua

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ local types = {
55
["storage-tank"] = true,
66
["boiler"] = true,
77
["pipe"] = true,
8-
["pipe-to-ground"] = true
8+
["pipe-to-ground"] = true,
9+
["generator"] = true,
910
}
1011

1112
local look_offset = 0.5
1213
local look_distance = 1
13-
local tank_surroundings_check_distance = 2
14+
local tank_surroundings_check_distance = 5
1415
local function get_tank(entity)
1516
local position = entity.position
1617
local direction = entity.direction
@@ -68,25 +69,37 @@ local function on_built(event)
6869
end
6970

7071
local function on_tick(event)
72+
-- entity update
7173
for _, combinator in pairs(global.combinators[event.tick % refresh_rate]) do
7274
local count = 0
75+
local fluid
7376
if combinator.tank and combinator.tank.valid and combinator.tank.fluidbox[1] then
77+
local fluidbox = combinator.tank.fluidbox[1]
7478
local precision = 1
7579
if combinator.precise then precision = 100 end
76-
count = combinator.tank.fluidbox[1].temperature * precision
80+
count = fluidbox.temperature * precision
81+
82+
fluid = {
83+
signal = {type = "fluid", name = fluidbox.type},
84+
count = math.floor(fluidbox.amount),
85+
index = 2
86+
}
7787
end
88+
7889
combinator.entity.get_or_create_control_behavior().parameters = {
7990
enabled = true,
8091
parameters = {
8192
{
8293
signal = {type = "virtual", name = "fluid-temperature"},
8394
count = math.floor(count),
8495
index = 1
85-
}
96+
},
97+
fluid
8698
}
8799
}
88100
end
89101

102+
-- GUI update
90103
for i = event.tick % gui_refresh_rate + 1, #game.players, gui_refresh_rate do
91104
local player = game.players[i]
92105
if player.opened and player.opened.name == "fluid-temperature-combinator" then

data-updates.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local name = "fluid-temperature-combinator"
33
local entity = util.table.deepcopy(data.raw["constant-combinator"]["constant-combinator"])
44
entity.name = name
55
entity.minable.result = name
6-
entity.item_slot_count = 1
6+
entity.item_slot_count = 2
77

88
local item = util.table.deepcopy(data.raw["item"]["constant-combinator"])
99
item.name = name

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.3",
3+
"version": "0.2.0",
44
"factorio_version": "0.14",
55
"title": "Fluid Temperature Combinator",
66
"author": "theRustyKnife",
7-
"description": "A combinator that can read the temperature of fluid in an adjacent tank, boiler or pipe.",
7+
"description": "A combinator that can read the temperature of fluid in an adjacent tank, boiler, generator or pipe.",
88
"homepage": "https://mods.factorio.com/mods/theRustyKnife/fluid-temperature-combinator",
9-
"date": "02.11.2016",
9+
"date": "10.11.2016",
1010
"dependencies": ["base"]
1111
}

0 commit comments

Comments
 (0)