feat: change sum_items for stock ticker
This commit is contained in:
parent
ecb7ff7c40
commit
4481b8e7fa
1 changed files with 4 additions and 3 deletions
|
|
@ -71,9 +71,9 @@ end
|
||||||
|
|
||||||
-- logic
|
-- logic
|
||||||
|
|
||||||
function sum_items (inv)
|
function sum_items (inv_f)
|
||||||
local result = {}
|
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
|
if result[item.name] == nil then result[item.name] = 0 end
|
||||||
result[item.name] = result[item.name] + item.count
|
result[item.name] = result[item.name] + item.count
|
||||||
end
|
end
|
||||||
|
|
@ -156,8 +156,9 @@ function print_counts (items)
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
|
local main_inv = peripheral.wrap(MAIN_TICKER)
|
||||||
-- 1. Sum items in inventory and organize by item type
|
-- 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)
|
-- print_counts(items)
|
||||||
|
|
||||||
-- 2. either work towards a desired distribution or create more resources
|
-- 2. either work towards a desired distribution or create more resources
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue