diff --git a/compacting-storage.lua b/compacting-storage.lua index 99df3ac..7d46c52 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -71,9 +71,9 @@ end -- logic -function sum_items (inv) +function sum_items (inv_f) local result = {} - for _, item in pairs(inv.list()) do + for _, item in pairs(inv_f()) do if result[item.name] == nil then result[item.name] = 0 end result[item.name] = result[item.name] + item.count end @@ -156,8 +156,9 @@ function print_counts (items) end while true do + local main_inv = peripheral.wrap(MAIN_TICKER) -- 1. Sum items in inventory and organize by item type - local items = sum_items(peripheral.wrap(INVENTORY)) + local items = sum_items(main_inv.stock) -- print_counts(items) -- 2. either work towards a desired distribution or create more resources