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 = turtle.inspectDown()
  64.         if blockBelow ~= nil then
  65.             turtle.down()
  66.             turtle.placeUp()
  67.     while blockBelow ~= nil
  68.     turtle.forward()
  69.     for i = 1, 2 do
  70.         turtle.turnRight()
  71.     end
  72.     turtle.place()
  73.     repeat
  74.         blockAbove = turtle.inspectUp()
  75.         if blockAbove ~= nil then
  76.             turtle.up()
  77.     while blockAbove ~= nil
  78.     turtle.back()
  79.     for i = 1, 2 do
  80.         turtle.up()
  81.     end
  82. end
  83.  
  84. function placePillars()
  85.     placePillar()
  86.     turtle.turnRight()
  87.     for i = 1, 4 do
  88.         turtle.forward()
  89.     end
  90.     turtle.turnLeft()
  91.     placePillar()
  92.     turtle.turnLeft()
  93.     for i = 1, 4 do
  94.         turtle.forward()
  95.     end
  96.     turtle.turnRight()
  97. end
  98.  
  99. function placeTorch()
  100.     turtle.up()
  101.     turtle.turnRight()
  102.     for i = 1, 3 do
  103.         turtle.forward()
  104.     end
  105.     turtle.turnRight()
  106.     selectBlock("minecraft:torch")
  107.     turtle.place()
  108.     turtle.turnRight()
  109.     for i = 1, 3 do
  110.         turtle.forward()
  111.     end
  112.     turtle.turnRight()
  113.     turtle.down()
  114. end
  115.  
  116. function placeBridgeChunk()
  117.     for i = 1, 2 do
  118.         turtle.turnRight()
  119.     end
  120.     turtle.up()
  121.     selectBlock("minecraft:stonebrick")
  122.     if bridgePos % 2 == 0 then
  123.         turtle.up()
  124.         turtle.place()
  125.         turtle.down()
  126.     end
  127.     turtle.place()
  128.     turtle.down()
  129.     turtle.turnLeft()
  130.     for i = 1, 7 do
  131.         turtle.turnRight()
  132.         turtle.place()
  133.         turtle.turnLeft()
  134.         turtle.forward()
  135.     end
  136.     turtle.down()
  137.     for i = 1, 2 do
  138.         turtle.turnRight()
  139.     end
  140.     turtle.forward()
  141.     for i = 1, 2 do
  142.         turtle.up()
  143.     end
  144.     turtle.turnLeft()
  145.     turtle.place()
  146.     if bridgePos % 2 == 0 then
  147.         turtle.up()
  148.         turtle.place()
  149.         turtle.down()
  150.     end
  151.     for i = 1, 2 do
  152.         turtle.down()
  153.     end
  154.     turtle.turnRight()
  155.     turtle.forward()
  156.     for i = 1, 4 do
  157.         turtle.turnLeft()
  158.         turtle.place()
  159.         turtle.turnRight()
  160.         turtle.forward()
  161.     end
  162.     turtle.place()
  163.     turtle.turnLeft()
  164.     turtle.down()
  165.     turtle.place()
  166.     turtle.turnLeft()
  167.     for i = 1, 4 do
  168.         turtle.forward()
  169.     end
  170.     turtle.turnRight()
  171.     turtle.place()
  172.     if bridgePos % 5 == 0 then
  173.         placePillars()
  174.     end
  175.     turtle.turnRight()
  176.     for i = 1, 2 do
  177.         turtle.up()
  178.     end
  179.     for i = 1, 5 do
  180.         turtle.forward()
  181.     end
  182.     turtle.turnRight()
  183. end
  184.  
  185. function clearSpace()
  186.     turtle.turnRight()
  187.     for i = 1, 3 do
  188.         upDig()
  189.     end
  190.     for i = 1, 6 do
  191.         for j = 1, 6 do
  192.             forwardDig()
  193.         end
  194.         for j = 1, 2 do
  195.             turtle.turnRight()
  196.         end
  197.         downDig()
  198.     end
  199.     for i = 1, 3 do
  200.         turtle.up()
  201.     end
  202.     turtle.turnLeft()
  203. end
  204.  
  205. function buildChunkOfBridge()
  206.     forwardDig()
  207.     clearSpace()
  208.     placeBridgeChunk()
  209.     if (bridgePos + 3) % 8 == 0 then
  210.         placeTorch()
  211.     end
  212.     bridgePos = bridgePos + 1
  213. end
  214.  
  215. function checkFuel()
  216.     fuelLevel = turtle.getFuelLevel()
  217.     if fuelLevel < 50 then
  218.         for i = 1, 16 do
  219.             turtle.select(i)
  220.             turtle.refuel(64)
  221.         end
  222.     end
  223. end
  224.  
  225. function mainLoop()
  226.    while true do
  227.        checkFuel()
  228.        buildChunkOfBridge()
  229.    end
  230. end
  231.  
  232. 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