Bug
In module/edge/belt_link.lua, the push_belt_link function attempts to compact leftover items back to the front of item_stacks when not all items fit in the chest. However the loop bounds are inverted, so the loop never runs and the caller cannot determine what remains.
Code
-- belt_link.lua:111-114
if item_stacks_count > space then
for index = 1, space - item_stacks_count do -- e.g. space=3, count=5 → range 1,-2 → never runs
item_stacks[index] = item_stacks[index + space]
end
Why it's wrong
space = slots available in the chest (items successfully placed)
item_stacks_count = total items to place
- When
item_stacks_count > space, space - item_stacks_count is negative
- In Lua,
for i = 1, -2 never executes (positive step, limit less than start)
- The leftover items at
item_stacks[space+1 .. item_stacks_count] are never shifted to the front
item_stacks is left with nil holes at the front and stale data at the back — the caller cannot tell what remains
Fix
Swap the operands and clear the trailing slots after the shift:
if item_stacks_count > space then
for index = 1, item_stacks_count - space do
item_stacks[index] = item_stacks[index + space]
end
for index = item_stacks_count - space + 1, item_stacks_count do
item_stacks[index] = nil
end
Impact
Items that don't fit in the destination chest are silently lost rather than being returned to the source for retry on the next tick.
Bug
In
module/edge/belt_link.lua, thepush_belt_linkfunction attempts to compact leftover items back to the front ofitem_stackswhen not all items fit in the chest. However the loop bounds are inverted, so the loop never runs and the caller cannot determine what remains.Code
Why it's wrong
space= slots available in the chest (items successfully placed)item_stacks_count= total items to placeitem_stacks_count > space,space - item_stacks_countis negativefor i = 1, -2never executes (positive step, limit less than start)item_stacks[space+1 .. item_stacks_count]are never shifted to the frontitem_stacksis left withnilholes at the front and stale data at the back — the caller cannot tell what remainsFix
Swap the operands and clear the trailing slots after the shift:
Impact
Items that don't fit in the destination chest are silently lost rather than being returned to the source for retry on the next tick.