DreamGamer

Block Placer

Dec 23rd, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function startTunnel(lenght)
  2.  
  3. local distance = 0
  4.  
  5. for i=1, lenght, 1 do
  6. checkBlock()
  7. dig()
  8. forward()
  9. checkBlock()
  10. turnRight(1)
  11. digUp()
  12. dig()
  13. forward()
  14. checkBlock()
  15. digUp()
  16. turnLeft(2)
  17. forward()
  18. turnRight(1)
  19.  
  20. distance = distance + 1
  21.  
  22. print("Distance: " .. distance)
  23.  
  24. end
  25.  
  26.  
  27. end
  28.  
  29.  
  30. function dig()
  31. while turtle.detect() do
  32. turtle.dig()
  33. end
  34.  
  35. end
  36.  
  37.  
  38. function forward()
  39. turtle.forward()
  40. end
  41.  
  42.  
  43. function checkBlock()
  44.  
  45. if turtle.getItemCount(1) > 0 then
  46. while not turtle.detectDown() do
  47. turtle.select(1)
  48. turtle.placeDown()
  49. end
  50. else
  51. print("No Blocks in slot 1!!!!")
  52. sleep(10)
  53. checkBlock()
  54. end
  55.  
  56. end
  57.  
  58.  
  59. function up()
  60. while turtle.detectUp() do
  61. turtle.digUp()
  62. end
  63. turtle.up()
  64.  
  65. end
  66.  
  67.  
  68. function digUp()
  69. while turtle.detectUp() do
  70. turtle.digUp()
  71. end
  72. end
  73.  
  74.  
  75.  
  76. function down()
  77. while turtle.detectDown() do
  78. turtle.digDown()
  79. end
  80. turtle.down()
  81.  
  82. end
  83.  
  84.  
  85. function digDown()
  86. while turtle.detectDown() do
  87. turtle.digDown()
  88. end
  89. end
  90.  
  91. function turnRight(e)
  92. for i1=1, e, 1 do
  93. turtle.turnRight()
  94. end
  95. end
  96.  
  97.  
  98. function turnLeft(e1)
  99. for i2=1, e1, 1 do
  100. turtle.turnLeft()
  101. end
  102. end
  103.  
  104.  
  105. print("Lenght: ")
  106. local lenght = read()
  107.  
  108.  
  109. startTunnel(lenght)
Advertisement
Add Comment
Please, Sign In to add comment