Advertisement
Guest User

Untitled

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