fa
This commit is contained in:
parent
ac604b7db0
commit
efd2cef8c4
8
IO.lua
8
IO.lua
@ -22,8 +22,12 @@ while true do
|
|||||||
local stacks_stored = d.map(chest.list(), w.to_wyvern_item)
|
local stacks_stored = d.map(chest.list(), w.to_wyvern_item)
|
||||||
local items_stored = w.collate_stacks(stacks_stored)
|
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
|
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
|
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)
|
local request = w.string_to_item(item_name)
|
||||||
request.type = "extract"
|
request.type = "extract"
|
||||||
@ -35,7 +39,7 @@ while true do
|
|||||||
|
|
||||||
for slot, item in pairs(stacks_stored) do
|
for slot, item in pairs(stacks_stored) do
|
||||||
local ii = w.get_internal_identifier(item)
|
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
|
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
|
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", {
|
local result = w.unwrap(w.query_by_type("storage", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user