Advertisement
ingrinder

Untitled

May 25th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. bridgePos = 0
  2.  
  3. function selectBlock(block)
  4. currentSelectedBlock = turtle.getItemDetail()
  5. if currentSelectedBlock ~= block then
  6. for i = 1, 16 do
  7. iBlockDetail = turtle.getItemDetail(i)
  8. if iBlockDetail ~= nil then
  9. if iBlockDetail.name == block then
  10. turtle.select(i)
  11. break
  12. end
  13. end
  14. if i == 16 then
  15. error("oh noes " .. block .. " ran out")
  16. end
  17. end
  18. end
  19. end
  20.  
  21. function forwardDig()
  22. blockInFront, blockInspect = turtle.inspect()
  23. if blockInFront then
  24. turtle.dig()
  25. end
  26. turtle.forward()
  27. end
  28.  
  29. function downDig()
  30. blockDown, blockInspect = turtle.inspectDown()
  31. if blockDown then
  32. turtle.digDown()
  33. end
  34. turtle.down()
  35. end
  36.  
  37. function upDig()
  38. blockUp, blockInspect = turtle.inspectUp()
  39. if blockUp then
  40. turtle.digUp()
  41. end
  42. turtle.up()
  43. end
  44.  
  45. function placePillar()
  46. for i = 1, 2 do
  47. turtle.down()
  48. end
  49. turtle.forward()
  50. selectBlock("minecraft:stone_brick_stairs")
  51. turtle.placeUp()
  52. for i = 1, 2 do
  53. turtle.forward()
  54. end
  55. for i = 1, 2 do
  56. turtle.turnRight()
  57. end
  58. turtle.placeUp()
  59. turtle.forward()
  60. selectBlock("minecraft:stonebrick")
  61. turtle.placeUp()
  62. repeat
  63. blockBelow, blockInfo = turtle.inspectDown()
  64. if blockBelow ~= nil then
  65. if blockInfo.name ~= "minecraft:water" then
  66. turtle.down()
  67. turtle.placeUp()
  68. end
  69. end
  70. until blockBelow ~= nil and blockInfo.name ~= "minecraft:water"
  71. digForward()
  72. for i = 1, 2 do
  73. turtle.turnRight()
  74. end
  75. turtle.place()
  76. repeat
  77. blockAbove = turtle.inspectUp()
  78. if blockAbove == nil then
  79. turtle.up()
  80. until blockAbove ~= nil
  81. turtle.back()
  82. for i = 1, 2 do
  83. turtle.up()
  84. end
  85. end
  86.  
  87. function placePillars()
  88. placePillar()
  89. turtle.turnRight()
  90. for i = 1, 4 do
  91. turtle.forward()
  92. end
  93. turtle.turnLeft()
  94. placePillar()
  95. turtle.turnLeft()
  96. for i = 1, 4 do
  97. turtle.forward()
  98. end
  99. turtle.turnRight()
  100. end
  101.  
  102. function placeTorch()
  103. turtle.up()
  104. turtle.turnRight()
  105. for i = 1, 3 do
  106. turtle.forward()
  107. end
  108. turtle.turnRight()
  109. selectBlock("minecraft:torch")
  110. turtle.place()
  111. turtle.turnRight()
  112. for i = 1, 3 do
  113. turtle.forward()
  114. end
  115. turtle.turnRight()
  116. turtle.down()
  117. end
  118.  
  119. function placeBridgeChunk()
  120. for i = 1, 2 do
  121. turtle.turnRight()
  122. end
  123. turtle.up()
  124. selectBlock("minecraft:stonebrick")
  125. if bridgePos % 2 == 0 then
  126. turtle.up()
  127. turtle.place()
  128. turtle.down()
  129. end
  130. turtle.place()
  131. turtle.down()
  132. turtle.turnLeft()
  133. for i = 1, 7 do
  134. turtle.turnRight()
  135. turtle.place()
  136. turtle.turnLeft()
  137. turtle.forward()
  138. end
  139. turtle.down()
  140. for i = 1, 2 do
  141. turtle.turnRight()
  142. end
  143. turtle.forward()
  144. for i = 1, 2 do
  145. turtle.up()
  146. end
  147. turtle.turnLeft()
  148. turtle.place()
  149. if bridgePos % 2 == 0 then
  150. turtle.up()
  151. turtle.place()
  152. turtle.down()
  153. end
  154. for i = 1, 2 do
  155. turtle.down()
  156. end
  157. turtle.turnRight()
  158. turtle.forward()
  159. for i = 1, 4 do
  160. turtle.turnLeft()
  161. turtle.place()
  162. turtle.turnRight()
  163. turtle.forward()
  164. end
  165. turtle.place()
  166. turtle.turnLeft()
  167. turtle.down()
  168. turtle.place()
  169. turtle.turnLeft()
  170. for i = 1, 4 do
  171. turtle.forward()
  172. end
  173. turtle.turnRight()
  174. turtle.place()
  175. if bridgePos % 5 == 0 then
  176. placePillars()
  177. end
  178. turtle.turnRight()
  179. for i = 1, 2 do
  180. turtle.up()
  181. end
  182. for i = 1, 5 do
  183. turtle.forward()
  184. end
  185. turtle.turnRight()
  186. end
  187.  
  188. function clearSpace()
  189. turtle.turnRight()
  190. for i = 1, 3 do
  191. upDig()
  192. end
  193. for i = 1, 6 do
  194. for j = 1, 6 do
  195. forwardDig()
  196. end
  197. for j = 1, 2 do
  198. turtle.turnRight()
  199. end
  200. downDig()
  201. end
  202. for i = 1, 3 do
  203. turtle.up()
  204. end
  205. turtle.turnLeft()
  206. end
  207.  
  208. function buildChunkOfBridge()
  209. forwardDig()
  210. clearSpace()
  211. placeBridgeChunk()
  212. if (bridgePos + 3) % 8 == 0 then
  213. placeTorch()
  214. end
  215. bridgePos = bridgePos + 1
  216. end
  217.  
  218. function checkFuel()
  219. fuelLevel = turtle.getFuelLevel()
  220. if fuelLevel < 50 then
  221. for i = 1, 16 do
  222. turtle.select(i)
  223. turtle.refuel(64)
  224. end
  225. end
  226. end
  227.  
  228. function mainLoop()
  229. while true do
  230. checkFuel()
  231. buildChunkOfBridge()
  232. end
  233. end
  234.  
  235. mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement