Advertisement
MyAsthma

hgf

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