From f8d3c9dda79e8e273e33671e1de0ae2cf4b5d97d Mon Sep 17 00:00:00 2001 From: osmarks Date: Mon, 13 Aug 2018 08:48:03 +0100 Subject: [PATCH] Add withdraw fully --- client.lua | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/client.lua b/client.lua index 0786a8a..2a7c3c1 100644 --- a/client.lua +++ b/client.lua @@ -37,10 +37,29 @@ local commands = { end local query = table.concat(query_tokens, " ") -- unsplit query - local items = w.query_by_type("storage", { + local items = unwrap(w.query_by_type("storage", { type = "search", query = query - }) + }), "searching for items") + + for _, item_type in pairs(items) do + do + local max_quantity + if quantity < 64 then max_quantity = quantity end + local moved = unwrap(w.query_by_type("storage", { + type = "extract", + ID = item_type.ID + meta = item_type.meta + NBT_hash = item_type.NBT_hash, + quantity = max_quantity, + destination_inventory = conf.network_name + }), "extracting a stack").moved + quantity = quantity - moved + item_type.count = item_type.count - moved + until quantity == 0 or item_type.count == 0 + end + + if quantity == 0 then break end end }