Skip to content

Commit

Permalink
Added boiler and pipe support
Browse files Browse the repository at this point in the history
  • Loading branch information
theRustyKnife committed Oct 25, 2016
1 parent e200794 commit 14be5bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
##0.1.1##
+Added support for boilers pipes and underground pipes

##0.1.0##
+ Initial release
15 changes: 12 additions & 3 deletions control.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
local refresh_rate = 60

local types = {
["storage-tank"] = true,
["boiler"] = true,
["pipe"] = true,
["pipe-to-ground"] = true
}

local look_offset = 0.5
local look_distance = 1
local tank_surroundings_check_distance = 2
Expand All @@ -19,7 +26,9 @@ local function get_tank(entity)
area = {{position.x + look_distance - 0.1, position.y - look_offset}, {position.x + look_distance + 0.1, position.y + look_offset}}
end

return entity.surface.find_entities_filtered{area = area, type = "storage-tank"}[1]
for i, v in pairs(entity.surface.find_entities(area)) do
if types[v.type] then return v end
end
end

local function find_in_global(combinator)
Expand All @@ -45,7 +54,7 @@ local function on_built(event)
entity.rotatable = true
table.insert(global.combinators[ei], {entity = entity, tank = get_tank(entity)})
end
if entity.type == "storage-tank" then
if types[entity.type] then
local area = {
{entity.position.x - tank_surroundings_check_distance, entity.position.y - tank_surroundings_check_distance},
{entity.position.x + tank_surroundings_check_distance, entity.position.y + tank_surroundings_check_distance}
Expand Down Expand Up @@ -96,7 +105,7 @@ local function on_destroyed(event)
end
end
end
if entity.type == "storage-tank" then
if types[entity.type] then
local area = {
{entity.position.x - tank_surroundings_check_distance, entity.position.y - tank_surroundings_check_distance},
{entity.position.x + tank_surroundings_check_distance, entity.position.y + tank_surroundings_check_distance}
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "fluid-temperature-combinator",
"version": "0.1.0",
"version": "0.1.1",
"factorio_version": "0.14",
"title": "Fluid Temperature Combinator",
"author": "theRustyKnife",
"description": "A combinator that can read the temperature of a fluid in adjacent tank.",
"description": "A combinator that can read the temperature of fluid in an adjacent tank, boiler or pipe.",
"homepage": "https://mods.factorio.com/mods/theRustyKnife/fluid-temperature-combinator",
"date": "25.10.2016",
"dependencies": []
Expand Down

0 comments on commit 14be5bc

Please sign in to comment.