Advertisement
Wassaa

sortSieve

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