Advertisement
skypop

CC Sort

Jul 23rd, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. -- Sort
  2. -- by SukaiPoppuGo
  3. -- required mod Plethora
  4.  
  5. local target = ... or "not set"
  6. local delay = 2
  7.  
  8. os.setComputerLabel("Sort")
  9.  
  10. local chest = peripheral.find(target)
  11. assert(chest, string.format("Peripheral \"%s\" not found", target))
  12.  
  13. os.loadAPI("listItem.lua")
  14. assert(listItem, "Require list API")
  15.  
  16. local function loop()
  17.     for slot, item in pairs(chest.list()) do
  18.         local dest, msg = listItem.get(item)
  19.         if dest then
  20.             if chest.pushItems(dest,slot) then
  21.                 print(string.format("Move %s to %s (%s)", item.name, dest, msg))
  22.             else
  23.                 print(string.format("Fail to move %s to %s (%s)", item.name, dest, msg))
  24.             end
  25.         else
  26.             print(string.format("Not supported: %s", item.name))
  27.         end
  28.     end
  29. end
  30.  
  31. while true do
  32.     loop()
  33.     sleep(delay)
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement