attayi

Turtle inventory cleaner

Dec 9th, 2015
2,195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. inv = peripheral.wrap("left") --or what ever side the antenna is on
  2.  
  3. --add as many things you want to keep
  4. Keep = {}
  5. Keep[1] = "Redstone"
  6. Keep[2] = "Yellorite Ore"
  7. Keep[3] = "Tin Ore"
  8. Keep[4] = "Copper Ore"
  9. Keep[5] = "Iron Ore"
  10. Keep[6] = "Certus Quartz Crystal"
  11. Keep[7] = "Diamond"
  12.  
  13. function within(t1, t2)
  14.     for t3,t4 in pairs(t2) do
  15.         if (t1 == t4) then
  16.             return true
  17.         end
  18.     end
  19. end
  20.  
  21. function clear_inv()
  22.     i = inv.getAllStacks(false)
  23.     for q,w in pairs(i) do 
  24.         name = w.display_name
  25.         if (within(name,Keep)) then
  26.             sleep(1)
  27.         elseif (name == "Coal") then
  28.             turtle.refuel(q)
  29.         else inv.destroyStack(q)
  30.         end
  31.     end
  32.     inv.condenseItems()
  33. end
  34.  
  35. while true do
  36.     clear_inv()
  37.     sleep(3)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment