Assembler Pipe Passthrough


Adds more pipe connections to allow assembling machines (including chem plants, oil-refineries (toggleable by settings)) to pass through fluids, like electric miners.

Content
6 days ago
0.17 - 2.0
7.46K
Fluids Manufacturing

i fix for the corners*

6 days ago
(updated 6 days ago)

Assembler Pipe Passthrough - Issue Fixes & Solutions

✅ Corner Entity Alt-Mode Overlap (MAIN FIX)

Problem: Fluid box connections on corner entities (oil refineries, chemical plants, cryogenic plants) overlapped with alt-mode display information.

Solution maybe: Implemented position offsetting for corner entities to move pipe connection indicators 0.3 tiles inward from entity edges.
preview (https://drive.google.com/uc?id=1dB9SxqGC-VjJQdm9RA3Z6wq-Wvlf_-zC)

Code Implementation:

-- Detect corner entities
local is_corner_entity = (entity.name == "oil-refinery" or entity.name == "chemical-plant" or 
                         string.find(entity.name, "cryogenic") or string.find(entity.name, "refinery"))

-- For INPUT connections (North/South):
if is_corner_entity then
  -- Offset south connection slightly inward (towards center)
  input_y_south = input_y_south - 0.3
  -- Offset north connection slightly inward (towards center)  
  input_y_north = input_y_north + 0.3
end

-- For OUTPUT connections (East/West):
if is_corner_entity then
  -- Offset east connection slightly inward (towards center)
  output_x_east = output_x_east - 0.3
  -- Offset west connection slightly inward (towards center)
  output_x_west = output_x_west + 0.3
end

Complete Code Changes

In process_fluidboxes() function:

local function process_fluidboxes(entity, entitytype)
  local entity = table.deepcopy(data.raw[entitytype][entity.name])
  local entity_size = get_entity_size_in_tiles(entity)

  -- NEW: Check if this is a corner entity that needs special handling
  local is_corner_entity = (entity.name == "oil-refinery" or entity.name == "chemical-plant" or 
                           string.find(entity.name, "cryogenic") or string.find(entity.name, "refinery"))


  if (entity_size[1] == entity_size[2]) then
    -- ... existing logic ...

    if fluidbox_types['input'] > 0 then
      if (fb.production_type == 'input') then
        -- NEW: Calculate base positions with corner entity offset
        local input_x = first_input_fb_pos[1] - (i_index * 2)
        local input_y_south = first_input_fb_pos[2]
        local input_y_north = -first_input_fb_pos[2]

        -- NEW: Apply corner entity offset
        if is_corner_entity then
          input_y_south = input_y_south - 0.3
          input_y_north = input_y_north + 0.3
        end

        fb.pipe_connections = {
          {
            position = { input_x, input_y_south },
            flow_direction = 'input-output',
            direction = defines.direction.south
          },
          {
            position = { input_x, input_y_north },
            flow_direction = 'input-output',
            direction = defines.direction.north
          }
        }

      end
    end

    if fluidbox_types['output'] > 0 then
      if fb.production_type == 'output' then
        -- NEW: Calculate base positions with corner entity offset
        local output_x_east = first_output_fb_pos[1]
        local output_x_west = -first_output_fb_pos[1]
        local output_y = first_output_fb_pos[2] - (o_index * 2)

        -- NEW: Apply corner entity offset
        if is_corner_entity then
          output_x_east = output_x_east - 0.3
          output_x_west = output_x_west + 0.3
        end

        fb.pipe_connections = {
          {
            position = { output_x_east, output_y },
            flow_direction = 'input-output',
            direction = defines.direction.east
          },
          {
            position = { output_x_west, output_y },
            flow_direction = 'input-output',
            direction = defines.direction.west
          }
        }

      end
    end
  end
end

6 days ago

i'm new to modding this game & new to lua in general, but i've been using this mods in all my saves so i thought if i could fix it or look up solutions that would be nice

This is good work, and you've given me some inspiration on how to resolve the underlying issue.

Your current proposed code has a few issues with it, namely:
1. Fluid box icons move away from the box they are supposed to be associated with, likely confusing players even more.
2. I want to avoid hard coding any form of list, as not to exclude entities that I've never come across before.

That said, I'll have a look and see if I can make the idea work.

30 minutes of inspiration later; new version is released.

Thanks watdafawx.

5 days ago

glad you figured it out coz i was never going to be able to with my limited knowledge of lua & the game api
great work <3

New response