Advertisement
Wassaa

sortDustChest

Nov 27th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. p = peripheral.wrap("back")
  2. items = p.getAllStacks()
  3. hammerDir = "Up"
  4. --MeDir = "Up"
  5.  
  6. function isHammerable(name)
  7.     if string.find(name, "Dust") ~= nil then
  8.         return 1
  9.     else
  10.         return 2
  11.     end
  12. end
  13.  
  14. function doSorting(_index)
  15.     if items[_index] ~= nil then
  16.         if isHammerable(p.getStackInSlot(_index)["display_name"]) == 1 then
  17.             p.pushItem(hammerDir, _index)
  18.         elseif isHammerable(p.getStackInSlot(_index)["display_name"]) == 0 then
  19.             p.pushItem(MeDir, _index)
  20.         else
  21.             print("keeping item here")
  22.         end
  23.     end
  24. end
  25.  
  26. function tableLength(T)
  27.   local count = 0
  28.   for _ in pairs(T) do count = count + 1 end
  29.   return count
  30. end
  31.  
  32. while true do
  33.     for i=1, 10 do
  34.         --term.clear()
  35.         local counts = 10-i
  36.         print ("Sleeping for: "..counts)
  37.         os.sleep(1)
  38.     end
  39.     print("found "..tableLength(items).." items to move")
  40.     p.condenseItems()
  41.     items = p.getAllStacks()   
  42.     table.foreach(items, doSorting)
  43.     print("Moving Items")
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement