Advertisement
Guest User

Turtle

a guest
Dec 11th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. length=5
  2. current=0
  3. faceDepth=4
  4. trials=5
  5.  
  6. function Forward()
  7. while not turtle.forward() do
  8. turtle.dig()
  9. turtle.attack()
  10. end
  11. end
  12.  
  13. function Up()
  14. while not turtle.up() do
  15. turtle.digUp()
  16. turtle.attackUp()
  17. end
  18. end
  19.  
  20. function Down()
  21. while not turtle.down() do
  22. turtle.digDown()
  23. turtle.attackDown()
  24. end
  25. end
  26.  
  27. function Dump()
  28. for slot=1,16 do
  29. turtle.select(slot)
  30. turtle.drop()
  31. end
  32. turtle.select(1)
  33. end
  34.  
  35. function Gravel()
  36. while turtle.detect() do
  37. turtle.dig()
  38. sleep(0.5)
  39. end
  40. end
  41.  
  42. function DigDown()
  43. for i=1,faceDepth do
  44. turtle.dig()
  45. turtle.digDown()
  46. Down()
  47. end
  48. turtle.dig()
  49. sleep(1)
  50. Gravel()
  51. for i=1,faceDepth do Up() end
  52. end
  53.  
  54. function DigFace()
  55. turtle.turnLeft()
  56. DigDown()
  57. turtle.turnRight() turtle.turnRight()
  58. DigDown()
  59. turtle.turnLeft()
  60. end
  61.  
  62. function EmptyInventory(dist)
  63. turtle.turnRight() turtle.turnRight()
  64. while current>0 do
  65. Forward()
  66. current=current-1
  67. end
  68. Down() Down() Down()
  69. Dump()
  70.  
  71. turtle.turnRight() turtle.turnRight()
  72. Up() Up() Up()
  73.  
  74. while current<dist do
  75. Forward()
  76. current=current+1
  77. end
  78. end
  79.  
  80. function DigTunnel()
  81. while current<length do
  82. DigFace()
  83. turtle.dig()
  84. Forward()
  85. current=current+1
  86. if turtle.getItemCount(16)>0 then EmptyInventory(current) end
  87. end
  88. EmptyInventory(0)
  89. end
  90.  
  91. function FindPosition()
  92. turtle.turnLeft()
  93. while not (turtle.detect()) do
  94. turtle.forward()
  95. end
  96. local success,data=turtle.inspect()
  97. if success and not (data.name=="computercraft:turtle_expanded") then
  98. turtle.dig() Forward()
  99. turtle.dig() Forward()
  100. turtle.turnRight()
  101. DigTunnel()
  102. else
  103. turtle.turnRight() sleep(5)
  104. end
  105. end
  106.  
  107.  
  108.  
  109. for i=1,trials do
  110. FindPosition()
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement