Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. local depth = 0
  2. local length = 20
  3. -- pokehole length
  4. local fuelNeeded = ((length/3)*20) + (length*2) + (depth*2)
  5. local function checkFuel()
  6. while (turtle.getFuelLevel() < fuelNeeded) do
  7. turtle.select(1)
  8. if (turtle.getItemCount(1) == 0) then
  9. print("Not enough fuel.")
  10. return false
  11. end
  12. turtle.refuel(1)
  13. end
  14. return true
  15. end
  16. local function checkTorches()
  17. if (length / 10 > turtle.getItemCount(2)) then
  18. print("Not enough torchs.")
  19. return false
  20. end
  21. return true
  22. end
  23. local function checkLadders()
  24. if (turtle.getItemCount(3) < depth) then
  25. print("Not enough ladders.")
  26. return false
  27. end
  28. return true
  29. end
  30. local function placeTorch()
  31. turtle.select(2)
  32. turtle.placeDown()
  33. end
  34. local function dig()
  35. while (turtle.detect()) do
  36. turtle.dig()
  37. sleep(0.5)
  38. end
  39. end
  40. local function digPokeHoles()
  41. local i = 0
  42. turtle.turnRight()
  43. for i=0, 4 do
  44. dig()
  45. turtle.forward()
  46. end
  47. turtle.turnLeft()
  48. turtle.turnLeft()
  49. for i=0, 4 do
  50. turtle.forward()
  51. end
  52. for i=0, 4 do
  53. dig()
  54. turtle.forward()
  55. end
  56. turtle.turnRight()
  57. turtle.turnRight()
  58. for i=0, 4 do
  59. turtle.forward()
  60. end
  61. turtle.turnLeft()
  62. end
  63. local function digToDepth()
  64. local ladder = false
  65. if (depth > 1) then
  66. ladder = true
  67. end
  68. if (ladder) then
  69. turtle.turnRight()
  70. turtle.turnRight()
  71. end
  72. local i = 0
  73. while (i < depth) do
  74. turtle.digDown()
  75. turtle.down()
  76. if (ladder) then
  77. turtle.dig()
  78. turtle.select(3)
  79. turtle.place()
  80. end
  81. i = i + 1
  82. end
  83. turtle.digDown()
  84. if (ladder) then
  85. turtle.down()
  86. turtle.dig()
  87. turtle.select(3)
  88. turtle.place()
  89. turtle.up()
  90. turtle.turnRight()
  91. turtle.turnRight()
  92. end
  93. placeTorch()
  94. digPokeHoles()
  95. end
  96. local function digTunnel()
  97. local i = 0
  98. local j = 0
  99. local k = 0
  100. while (i < length) do
  101. dig()
  102. turtle.forward()
  103. turtle.digDown()
  104. j = j + 1
  105. if (j == 10) then
  106. placeTorch()
  107. j = 0
  108. end
  109. k = k + 1
  110. if (k % 3 == 0) then
  111. digPokeHoles()
  112. k = 0
  113. end
  114. i = i + 1
  115. end
  116. end
  117. local function turnAround()
  118. turtle.turnRight()
  119. turtle.turnRight()
  120. end
  121. local function moveToTunnelStart()
  122. local i = 0
  123. for i=1,length do
  124. turtle.forward()
  125. end
  126. end
  127. local function moveToStartDepth()
  128. local i = 0
  129. for i=1,depth do
  130. turtle.up()
  131. end
  132. end
  133. local function placeSafetyBlock()
  134. turtle.select(4)
  135. turtle.placeDown()
  136. print("Complete.")
  137. end
  138.  
  139. --If not enough fuel, torches or ladders don't do anything.
  140. if checkFuel() and checkTorches() and checkLadders() then
  141. digToDepth()
  142. digTunnel()
  143. placeTorch()
  144. turnAround()
  145. moveToTunnelStart()
  146. turnAround()
  147. moveToStartDepth()
  148. placeSafetyBlock()
  149. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement