Advertisement
Guest User

te

a guest
Jun 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. inPit = false
  2. loops = 1
  3.  
  4. local function forward(count)
  5. if count == nil then count = 1 end
  6. for i = 1, count do
  7. turtle.forward()
  8. end
  9. end
  10.  
  11. local function up(count)
  12. if count == nil then count = 1 end
  13. for i = 1, count do
  14. turtle.up()
  15. end
  16. end
  17.  
  18. local function down(count)
  19. if count == nil then count = 1 end
  20. for i = 1, count do
  21. turtle.down()
  22. end
  23. end
  24.  
  25. local function turnLeft(count)
  26. if count == nil then count = 1 end
  27. for i = 1, count do
  28. turtle.turnLeft()
  29. end
  30. end
  31.  
  32. local function turnRight(count)
  33. if count == nil then count = 1 end
  34. for i = 1, count do
  35. turtle.turnRight()
  36. end
  37. end
  38.  
  39. local function enterPit()
  40. forward(3)
  41. down()
  42. inPit = true
  43. return true
  44. end
  45.  
  46. local function exitPit()
  47. turnLeft(2)
  48. up()
  49. forward(3)
  50. turnLeft(2)
  51. inPit = false
  52. return true
  53. end
  54.  
  55. local function deposit()
  56. if inPit then
  57. exitPit()
  58. end
  59. turnLeft()
  60. turtle.up()
  61. forward(2)
  62. for i = 3,16 do
  63. turtle.select(i)
  64. turtle.dropDown()
  65. end
  66. turtle.select(1)
  67. turnRight(2)
  68. forward(2)
  69. turtle.down()
  70. turnLeft()
  71. return true
  72. end
  73.  
  74. local function refuel(count)
  75. if count == nil then count = 1 end
  76. function fuelUp()
  77. up()
  78. os.sleep(4)
  79. down()
  80. turtle.placeDown()
  81. turtle.refuel()
  82. end
  83. if inPit then
  84. exitPit()
  85. end
  86. deposit()
  87. forward()
  88. turnRight()
  89. turtle.select(2)
  90. turtle.place()
  91. turtle.select(1)
  92. turnLeft()
  93. forward(2)
  94. down()
  95. turtle.digDown()
  96. os.sleep(25)
  97. for i = 1, count do
  98. fuelUp()
  99. end
  100. exitPit()
  101. forward()
  102. turnRight()
  103. turtle.dig()
  104. turtle.select(3)
  105. turtle.transferTo(2)
  106. turnRight()
  107. forward()
  108. turnRight(2)
  109. return true
  110. end
  111.  
  112. local function regen()
  113. if inPit then
  114. exitPit()
  115. end
  116. forward()
  117. turnRight()
  118. turtle.select(2)
  119. turtle.place()
  120. turtle.select(1)
  121. os.sleep(25)
  122. turtle.dig()
  123. turnRight()
  124. forward()
  125. turnRight(2)
  126. end
  127.  
  128. local function digLoopOnce()
  129. function turnCorner()
  130. forward()
  131. turnRight()
  132. forward()
  133. end
  134. turtle.digDown()
  135. turnLeft()
  136. turnCorner()
  137. turtle.digDown()
  138. turnCorner()
  139. turtle.digDown()
  140. turnCorner()
  141. turtle.digDown()
  142. turnCorner()
  143. turnRight()
  144. end
  145.  
  146. local function start()
  147. if ~inPit then
  148. enterPit()
  149. end
  150. for i = 1,loops do
  151. if turtle.getFuelLevel() < 20000 then
  152. exitPit()
  153. refuel(20)
  154. enterPit()
  155. end
  156.  
  157. digLoopOnce()
  158. regen()
  159. if turtle.getItemCount(16) > 0 then
  160. exitPit()
  161. deposit()
  162. enterPit()
  163. end
  164. end
  165. if inPit then
  166. exitPit()
  167. end
  168. end
  169.  
  170. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement