This commit is contained in:
osmarks 2018-08-15 17:37:18 +01:00
parent ac604b7db0
commit efd2cef8c4
1 changed files with 6 additions and 2 deletions

8
IO.lua
View File

@ -22,8 +22,12 @@ while true do
local stacks_stored = d.map(chest.list(), w.to_wyvern_item)
local items_stored = w.collate_stacks(stacks_stored)
local function get_item_count(ii)
return (items_stored[ii] or {count = 0}).count
end
for item_name, quantity_desired in pairs(conf.items) do
local quantity_stocked = items_stored[item_name].count or 0
local quantity_stocked = get_item_count(item_name)
if quantity_desired > quantity_stocked then -- if we have fewer items than are desired, extract some from store
local request = w.string_to_item(item_name)
request.type = "extract"
@ -35,7 +39,7 @@ while true do
for slot, item in pairs(stacks_stored) do
local ii = w.get_internal_identifier(item)
local stored = (items_stored[ii] or {count = 0}).count
local stored = get_item_count(ii)
local wanted = conf.items[ii] or 0
if (get_num_stacks(stored) * 64) >= wanted then -- if item is not in want list or we have too many, send it back to storage
local result = w.unwrap(w.query_by_type("storage", {