Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. shaftLength = 200
  2. minimumFuel = 500
  3. linesAlreadyDone = 2
  4.  
  5. function itemIs(name)
  6. if (turtle.getItemDetail() and turtle.getItemDetail().name == ("minecraft:" .. name)) then
  7. if (name == "cobblestone") then
  8. if (turtle.getItemCount() > 1) then
  9. return true
  10. else
  11. return false
  12. end
  13. else
  14. return true
  15. end
  16. else
  17. return false
  18. end
  19. end
  20.  
  21. function blockIs(name)
  22. test, table = turtle.inspect()
  23. if (test and table.name == ("minecraft:" .. name)) then
  24. return true
  25. else
  26. return false
  27. end
  28. end
  29.  
  30. function blockDownIs(name)
  31. test, table = turtle.inspectDown()
  32. if (test and table.name == ("minecraft:" .. name)) then
  33. return true
  34. else
  35. return false
  36. end
  37. end
  38.  
  39. function blockUpIs(name)
  40. test, table = turtle.inspect()
  41. if (test and table.name == ("minecraft:" .. name)) then
  42. return true
  43. else
  44. return false
  45. end
  46. end
  47.  
  48. function dig()
  49. block = turtle.inspect()
  50. if (blockIs("chest") or blockIs("hopper")) then
  51. os.pullEvent("key")
  52. end
  53. turtle.dig()
  54. end
  55.  
  56. function fill()
  57. turtle.select(2)
  58. if (itemIs("cobblestone")) then
  59. turtle.place()
  60. end
  61. end
  62.  
  63. function fillDown()
  64. turtle.select(2)
  65. if (itemIs("cobblestone")) then
  66. turtle.placeDown()
  67. end
  68. end
  69.  
  70. function fillUp()
  71. turtle.select(2)
  72. if (itemIs("cobblestone")) then
  73. turtle.placeUp()
  74. end
  75. end
  76.  
  77. function refuel()
  78. if (turtle.getFuelLevel() < minimumFuel) then
  79. for i=1,16 do
  80. turtle.select(i)
  81. if (itemIs("coal")) then
  82. while(turtle.getFuelLevel() < minimumFuel and turtle.getItemCount() > 0) do
  83. turtle.refuel(1)
  84. end
  85. end
  86. end
  87. end
  88. end
  89.  
  90. function forward()
  91. refuel()
  92. if (blockIs("lava") or blockIs("water")) then
  93. fill()
  94. turtle.dig()
  95. turtle.forward()
  96. if (blockUpIs("lava") or blockUpIs("water")) then
  97. fillUp()
  98. end
  99. turtle.turnLeft()
  100. if (blockIs("lava") or blockIs("water")) then
  101. fill()
  102. end
  103. turtle.turnRight()
  104. turtle.turnRight()
  105. if (blockIs("lava") or blockIs("water")) then
  106. fill()
  107. end
  108. turtle.turnLeft()
  109. elseif (not turtle.foward()) then
  110. if (blockIs("gravel") or blockIs("sand")) then
  111. dig()
  112. while (not turtle.forward()) do
  113. dig()
  114. end
  115. end
  116. end
  117. if (blockDownIs("lava") or blockDownIs("water")) then
  118. turtle.select(2)
  119. if (itemIs("cobblestone")) then
  120. placeDown()
  121. end
  122. end
  123. end
  124.  
  125. function digShaft()
  126. for i=1, shaftLength do
  127. dig()
  128. forward()
  129. digUp()
  130. end
  131. end
  132.  
  133. function digShaftWidth(n)
  134. for j = 1, n do
  135. for i = 1,4 do
  136. dig()
  137. forward()
  138. digUp()
  139. end
  140. end
  141. end
  142.  
  143. function dropOff()
  144. refuel()
  145. for i=2,16 do
  146. turtle.select(i)
  147. if (i == 2) then
  148. turtle.drop(turtle.getItemCount() - 1)
  149. else
  150. if (itemIs("coal")) then
  151. turtle.drop(32)
  152. else
  153. turtle.drop()
  154. end
  155. end
  156. end
  157. end
  158.  
  159. function stripMine(alreadyDone)
  160. for i = 1 + alreadyDone, 6 do
  161. if (i > 1) then
  162. turtle.turnRight()
  163. digShaftWidth(2*(i-1))
  164. turtle.turnLeft()
  165. end
  166. digShaft()
  167. turtle.turnRight()
  168. digShaftWidth(1)
  169. turtle.turnRight()
  170. digShaft()
  171. turtle.turnRight()
  172. digShaftWidth(2*i - 1)
  173. turtle.turnLeft()
  174. dropOff()
  175. turtle.turnLeft()
  176. turtle.turnLeft()
  177. end
  178. end
  179.  
  180. stripMine(linesAlreadyDone)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement