BeltRouter Lite

by plexpt

This mod allows you to route belts and pipes automatically: 1. Put the starting belt and ending belt on ground first, 2. then select the starting belt with control+right-click and 3. select a ending belt with control+left-click. Boom, belt ghosts are created! (hint: you can also disable underground belt by shift+ctrl+left-click at the ending belt)

Utilities
4 months ago
1.1 - 2.0
5.61K

g Fix for Pipe Bug

4 months ago
(updated 4 months ago)

In path_segment.lua replaced Vector2D.fromDirection(self.direction):reverse():toDirection() with DirectionHelper.reverseOf(self.direction)

function PathSegment:toEntitySpecs()
    local type = EntityRoutingAttribute.from(self.name)
    if type.isUnderground == false then
        if self.distance == 1 then
            return {
                { name = self.name, direction = self.direction, position = self.position }
            }
        else
            -- although we basically don't include multiple onGround segments into one PathSegment, but I'll provide algorithm here
            local out = {}
            for dist = 0, self.distance - 1, 1 do
                out[#out + 1] = { name = self.name, direction = self.direction, position = self.position + Vector2D.fromDirection(self.direction):scale(dist) }
            end
            return out
        end
    else
        if type.lineType == TransportLineType.fluidLine then
            local out = {}
            -- Fixed: Use DirectionHelper.reverseOf() instead of reversing the vector
            out[1] = { name = self.name, direction = DirectionHelper.reverseOf(self.direction), position = self.position }
            if self.distance > 1 then
                out[2] = { name = self.name, direction = self.direction, position = self.position + Vector2D.fromDirection(self.direction):scale(self.distance - 1) }
            end
            return out
        else
            if self.distance == 1 then
                return {
                    { name = self.name, direction = self.direction, position = self.position, type = self.type }
                }
            else
                return {
                    { name = self.name, direction = self.direction, position = self.position, type = "input" },
                    { name = self.name, direction = self.direction, position = self.position + Vector2D.fromDirection(self.direction):scale(self.distance - 1), type = "output" }
                }
            end
        end
    end
end

The bug is in how the direction is being handled for the first underground pipe entity. Currently it's reversing both the vector AND converting it back to a direction, which results in incorrect rotation. It should only reverse the direction itself

4 months ago

tks

4 months ago

Updated, should have fixed it

New response