diff --git a/backend-chests.lua b/backend-chests.lua index e77bfd1..fc28679 100644 --- a/backend-chests.lua +++ b/backend-chests.lua @@ -137,7 +137,7 @@ end local function update_slot(inv, slot, by) index[inv][slot].count = index[inv][slot].count - by if index[inv][slot].count == 0 then index[inv][slot] = nil - elseif index[inv][lot].count < 0 then os.queueEvent "reindex" error "Index inconsistency error." end + elseif index[inv][slot].count < 0 then os.queueEvent "reindex" error "Index inconsistency error." end end local function server(command) @@ -193,7 +193,9 @@ local function server(command) local moved = 0 for _, loc in pairs(space_locations) do - moved = moved + peripheral.call(conf.buffer_internal, "pushItems", loc.inventory, BUFFER_IN_SLOT, 64, loc.slot) -- push from buffer to free space + local moved_now = peripheral.call(conf.buffer_internal, "pushItems", loc.inventory, BUFFER_IN_SLOT, 64, loc.slot) -- push from buffer to free space + update_slot(loc.inventory, loc.slot, -moved_now) + moved = moved + moved_now end return { moved = moved }