Belt Reverser Fixed


Reverse entire segments of belt

a month ago
2.0
341
Logistics Logistic network

b Non Recoverable Error.

a month ago
(updated a month ago)

I got this while dragging Rails over Belts and hitting G to switch Rail Layers.

The mod Belt Reverser Fixed (0.1.1) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event belt-reverserup-fixed::ReverseEntireBelt (ID 199)
belt-reverserup-fixed/flipBeltLines.lua:19: 'for' limit must be a number
stack traceback:
belt-reverserup-fixed/flipBeltLines.lua:19: in function 'replaceBeltLane'
belt-reverserup-fixed/flipBeltLines.lua:11: in function 'flipBeltLines'
belt-reverserup-fixed/control.lua:211: in function 'reverseBelt'
belt-reverserup-fixed/control.lua:226: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:225: in function 'reverseDownstreamBelts'
belt-reverserup-fixed/control.lua:238: in function <belt-reverserup-fixed/control.lua:230>

a month ago

Update :
It got nothing to do with Rails. Just happens if I press G on a belt.

I also have Belt Visualizer which also uses the G Key.
I also have a decent amount of mods but Im unsure how to post them here efficiently as a text.

a month ago

Ran into the same problem. It's because how items are stored on belts changed.

The method M.replaceBeltLane should look something like this:

function M.replaceBeltLane(lane, contents)
    lane.clear()
    local currentPosition = 0
    for i, item in ipairs(contents) do
        for _ = 1, item.count do
            lane.insert_at(currentPosition, {name=item.name, count=1})
            currentPosition = currentPosition + 0.03125 * 9
        end
    end

end

However, playing with it some more it looks like sometimes items are being deleted off the belt when it's rotated. Internally the code is copying the items and putting them back on the belt, presumably to prevent spilling items off the belt at corners as things rotate. Since rotation no longer spills the belts off, it looks like everything having to do with item cloning can be removed. I imagine it breaks when there are stacks of items or items with quality anyhow. Instead, all it really needs to do is call belt.rotate() on underground belts (though only on one side), and do something like this on regular belts (instead of calling flipBeltLine

local cw = (belt.direction + 4) % 16
local ccw = (belt.direction - 4) % 16

if direction == cw then
    belt.rotate()
elseif direction == ccw then
    belt.rotate({reverse = true})
else
    belt.rotate()
    belt.rotate()
end

New response