Advertisement
Wassaa

test

Nov 27th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 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(nr)
  15.     if items[nr] ~= nil then
  16.         if isHammerable(p.getStackInSlot(nr)["display_name"]) == 1 then
  17.             p.pushItem(hammerDir, nr)
  18.         elseif isHammerable(p.getStackInSlot(nr)["display_name"]) == 0 then
  19.             p.pushItem(MeDir, nr)
  20.         else
  21.             print("keeping "..p.getStackInSlot(nr)["display_name"].." 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.     p.condenseItems()
  34.     for i=1, 10 do
  35.         --term.clear()
  36.         local counts = 10-i
  37.         print ("Sleeping for: "..counts)
  38.         os.sleep(1)
  39.     end
  40.     print("found "..tableLength(items).." items to move")
  41.     items = p.getAllStacks()   
  42.     --table.foreach(items, doSorting)
  43.     for i=1, tableLength(items) do
  44.         if pcall(doSorting,i) then
  45.             --print("sorting success")
  46.         else
  47.             print("sorting failed")
  48.         end
  49.     end
  50.     --print("Moving Items")
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement