DreamGamer

Block placer 2x2

Dec 23rd, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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. print("dig")
  36. end
  37.  
  38.  
  39. function forward()
  40. while not turtle.forward() do
  41. turtle.dig()
  42. end
  43.  
  44. turtle.forward()
  45. print("forward")
  46. end
  47.  
  48.  
  49. function checkBlock()
  50.  
  51. if turtle.getItemCount(1) > 0 then
  52. while not turtle.detectDown() do
  53. turtle.select(1)
  54. turtle.placeDown()
  55. end
  56. else
  57. print("No Blocks in slot 1!!!!")
  58. sleep(10)
  59. checkBlock()
  60. end
  61.  
  62. end
  63.  
  64.  
  65. function up()
  66. while turtle.detectUp() do
  67. turtle.digUp()
  68. end
  69. turtle.up()
  70.  
  71. end
  72.  
  73.  
  74. function digUp()
  75. while turtle.detectUp() do
  76. turtle.digUp()
  77. end
  78. print("dig up")
  79. end
  80.  
  81.  
  82.  
  83. function down()
  84. while turtle.detectDown() do
  85. turtle.digDown()
  86. end
  87. turtle.down()
  88.  
  89. end
  90.  
  91.  
  92. function digDown()
  93. while turtle.detectDown() do
  94. turtle.digDown()
  95. end
  96.  
  97. print("dig down")
  98. end
  99.  
  100. function turnRight(e)
  101. for i1=1, e, 1 do
  102. turtle.turnRight()
  103. end
  104. end
  105.  
  106.  
  107. function turnLeft(e1)
  108. for i2=1, e1, 1 do
  109. turtle.turnLeft()
  110. end
  111. end
  112.  
  113.  
  114. print("Lenght: ")
  115. local lenght = read()
  116.  
  117.  
  118. startTunnel(lenght)
Advertisement
Add Comment
Please, Sign In to add comment