Advertisement
Hubnester

Untitled

Mar 11th, 2021 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. local drawers = peripheral.wrap("top")
  2. local sieves = peripheral.wrap("bottom")
  3. local i = 1
  4.  
  5. term.clear()
  6.  
  7. while true do
  8. local drawerItems = drawers.list()
  9. term.setCursorPos(1, 1)
  10. if not next(sieves.list()) and next(drawerItems) then
  11. local items = {}
  12. for i, item in pairs (drawerItems) do
  13. item.slot = i
  14. table.insert(items, item)
  15. end
  16. table.sort(items, function(a, b)
  17. return a.slot < b.slot
  18. end)
  19. i = (i % #items) + 1 -- To ensure it doesn't get out of bounds (the + 1 is due to it decreasing the number by 1 (sort of))
  20. term.write("Pushed " .. drawers.pushItems("bottom", items[i].slot, 25) .. " " .. items[i].name .. " ")
  21. i = i + 1
  22. elseif not next(sieves.list()) then
  23. term.write("No input items ")
  24. else
  25. term.write("Items already in the output ")
  26. end
  27. sleep(0)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement