11local refresh_rate = 60
22
3+ local types = {
4+ [" storage-tank" ] = true ,
5+ [" boiler" ] = true ,
6+ [" pipe" ] = true ,
7+ [" pipe-to-ground" ] = true
8+ }
9+
310local look_offset = 0.5
411local look_distance = 1
512local tank_surroundings_check_distance = 2
@@ -19,7 +26,9 @@ local function get_tank(entity)
1926 area = {{position .x + look_distance - 0.1 , position .y - look_offset }, {position .x + look_distance + 0.1 , position .y + look_offset }}
2027 end
2128
22- return entity .surface .find_entities_filtered {area = area , type = " storage-tank" }[1 ]
29+ for i , v in pairs (entity .surface .find_entities (area )) do
30+ if types [v .type ] then return v end
31+ end
2332end
2433
2534local function find_in_global (combinator )
@@ -45,7 +54,7 @@ local function on_built(event)
4554 entity .rotatable = true
4655 table.insert (global .combinators [ei ], {entity = entity , tank = get_tank (entity )})
4756 end
48- if entity .type == " storage-tank " then
57+ if types [ entity .type ] then
4958 local area = {
5059 {entity .position .x - tank_surroundings_check_distance , entity .position .y - tank_surroundings_check_distance },
5160 {entity .position .x + tank_surroundings_check_distance , entity .position .y + tank_surroundings_check_distance }
@@ -96,7 +105,7 @@ local function on_destroyed(event)
96105 end
97106 end
98107 end
99- if entity .type == " storage-tank " then
108+ if types [ entity .type ] then
100109 local area = {
101110 {entity .position .x - tank_surroundings_check_distance , entity .position .y - tank_surroundings_check_distance },
102111 {entity .position .x + tank_surroundings_check_distance , entity .position .y + tank_surroundings_check_distance }
0 commit comments