Advertisement
100Toby1

Untitled

Mar 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. p = peripheral.wrap("right")
  2.  
  3. function getItemSlots()
  4. local slots = 16
  5. for i = 1, 16 do
  6. if turtle.getItemCount(i) > 0 then
  7. slots = slots - 1
  8. end
  9. end
  10. return slots
  11. end
  12.  
  13. function autoRefuel()
  14. if turtle.getFuelLevel() <= 80 then
  15. turtle.refuel(1)
  16. end
  17. end
  18.  
  19. function dropAllItems()
  20. for i = 1, 16 do
  21. turtle.select(i)
  22. turtle.drop()
  23. end
  24. end
  25.  
  26. function dig()
  27. autoRefuel()
  28. while turtle.inspect() do
  29. p.dig()
  30. turtle.suck()
  31. os.sleep(0.5)
  32. end
  33. end
  34.  
  35. function digUp()
  36. autoRefuel()
  37. while turtle.inspectUp() do
  38. p.digUp()
  39. turtle.suck()
  40. os.sleep(0.5)
  41. end
  42. end
  43.  
  44. function digDown()
  45. autoRefuel()
  46. while turtle.inspectDown() do
  47. p.digDown()
  48. turtle.suck()
  49. os.sleep(0.5)
  50. end
  51. end
  52.  
  53. while true do
  54. autoRefuel()
  55.  
  56. while getItemSlots() > 0 do
  57. if turtle.inspect() then
  58. dig()
  59. turtle.turnRight()
  60. dig()
  61. turtle.turnLeft()
  62. turtle.turnLeft()
  63. dig()
  64. turtle.turnRight()
  65. digUp()
  66. turtle.up()
  67. dig()
  68. turtle.turnRight()
  69. dig()
  70. turtle.turnLeft()
  71. turtle.turnLeft()
  72. dig()
  73. turtle.turnRight()
  74. turtle.down()
  75. end
  76. turtle.forward()
  77. end
  78. --Turtle ran out of space
  79. turtle.turnRight()
  80. turtle.turnRight()
  81. --Turn Back
  82. while true do
  83. local _,data = turtle.inspect()
  84. if data.name == "IronChest:BlockIronChest" then break end
  85. autoRefuel()
  86. turtle.forward()
  87. end
  88. dropAllItems()
  89. turtle.turnRight()
  90. turtle.turnRight()
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement