Update client barrel auto-sort to trigger only when items are present
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user