SHARE
TWEET

Untitled

ingrinder May 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         end
  81.     until blockAbove ~= nil
  82.     turtle.back()
  83.     for i = 1, 2 do
  84.         turtle.up()
  85.     end
  86. end
  87.  
  88. function placePillars()
  89.     placePillar()
  90.     turtle.turnRight()
  91.     for i = 1, 4 do
  92.         turtle.forward()
  93.     end
  94.     turtle.turnLeft()
  95.     placePillar()
  96.     turtle.turnLeft()
  97.     for i = 1, 4 do
  98.         turtle.forward()
  99.     end
  100.     turtle.turnRight()
  101. end
  102.  
  103. function placeTorch()
  104.     turtle.up()
  105.     turtle.turnRight()
  106.     for i = 1, 3 do
  107.         turtle.forward()
  108.     end
  109.     turtle.turnRight()
  110.     selectBlock("minecraft:torch")
  111.     turtle.place()
  112.     turtle.turnRight()
  113.     for i = 1, 3 do
  114.         turtle.forward()
  115.     end
  116.     turtle.turnRight()
  117.     turtle.down()
  118. end
  119.  
  120. function placeBridgeChunk()
  121.     for i = 1, 2 do
  122.         turtle.turnRight()
  123.     end
  124.     turtle.up()
  125.     selectBlock("minecraft:stonebrick")
  126.     if bridgePos % 2 == 0 then
  127.         turtle.up()
  128.         turtle.place()
  129.         turtle.down()
  130.     end
  131.     turtle.place()
  132.     turtle.down()
  133.     turtle.turnLeft()
  134.     for i = 1, 7 do
  135.         turtle.turnRight()
  136.         turtle.place()
  137.         turtle.turnLeft()
  138.         turtle.forward()
  139.     end
  140.     turtle.down()
  141.     for i = 1, 2 do
  142.         turtle.turnRight()
  143.     end
  144.     turtle.forward()
  145.     for i = 1, 2 do
  146.         turtle.up()
  147.     end
  148.     turtle.turnLeft()
  149.     turtle.place()
  150.     if bridgePos % 2 == 0 then
  151.         turtle.up()
  152.         turtle.place()
  153.         turtle.down()
  154.     end
  155.     for i = 1, 2 do
  156.         turtle.down()
  157.     end
  158.     turtle.turnRight()
  159.     turtle.forward()
  160.     for i = 1, 4 do
  161.         turtle.turnLeft()
  162.         turtle.place()
  163.         turtle.turnRight()
  164.         turtle.forward()
  165.     end
  166.     turtle.place()
  167.     turtle.turnLeft()
  168.     turtle.down()
  169.     turtle.place()
  170.     turtle.turnLeft()
  171.     for i = 1, 4 do
  172.         turtle.forward()
  173.     end
  174.     turtle.turnRight()
  175.     turtle.place()
  176.     if bridgePos % 5 == 0 then
  177.         placePillars()
  178.     end
  179.     turtle.turnRight()
  180.     for i = 1, 2 do
  181.         turtle.up()
  182.     end
  183.     for i = 1, 5 do
  184.         turtle.forward()
  185.     end
  186.     turtle.turnRight()
  187. end
  188.  
  189. function clearSpace()
  190.     turtle.turnRight()
  191.     for i = 1, 3 do
  192.         upDig()
  193.     end
  194.     for i = 1, 6 do
  195.         for j = 1, 6 do
  196.             forwardDig()
  197.         end
  198.         for j = 1, 2 do
  199.             turtle.turnRight()
  200.         end
  201.         downDig()
  202.     end
  203.     for i = 1, 3 do
  204.         turtle.up()
  205.     end
  206.     turtle.turnLeft()
  207. end
  208.  
  209. function buildChunkOfBridge()
  210.     forwardDig()
  211.     clearSpace()
  212.     placeBridgeChunk()
  213.     if (bridgePos + 3) % 8 == 0 then
  214.         placeTorch()
  215.     end
  216.     bridgePos = bridgePos + 1
  217. end
  218.  
  219. function checkFuel()
  220.     fuelLevel = turtle.getFuelLevel()
  221.     if fuelLevel < 50 then
  222.         for i = 1, 16 do
  223.             turtle.select(i)
  224.             turtle.refuel(64)
  225.         end
  226.     end
  227. end
  228.  
  229. function mainLoop()
  230.    while true do
  231.        checkFuel()
  232.        buildChunkOfBridge()
  233.    end
  234. end
  235.  
  236. mainLoop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top