diff --git a/inventoryClient.lua b/inventoryClient.lua index 1bbc082..205ea7d 100644 --- a/inventoryClient.lua +++ b/inventoryClient.lua @@ -1384,12 +1384,18 @@ local function main() end end, - -- Task 4: Client barrel auto-sort (sends to master) + -- Task 4: Client barrel auto-sort (sends to master only when barrel has items) function() if CLIENT_BARREL_NAME == "" then return end print("[OK] Client barrel: " .. CLIENT_BARREL_NAME) while true do - sendToMaster({ type = "sort_barrel", barrelName = CLIENT_BARREL_NAME }) + local barrel = peripheral.wrap(CLIENT_BARREL_NAME) + if barrel then + local contents = barrel.list() + if contents and next(contents) then + sendToMaster({ type = "sort_barrel", barrelName = CLIENT_BARREL_NAME }) + end + end sleep(2) end end,