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