Advertisement
100Toby1

Untitled

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