Advertisement
Guest User

Untitled

a guest
May 27th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.68 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.     selectBlock("minecraft:stone_brick_stairs")
  59.     turtle.placeUp()
  60.     turtle.forward()
  61.     selectBlock("minecraft:stonebrick")
  62.     turtle.placeUp()
  63.     repeat
  64.         blockBelow, blockInfo = turtle.inspectDown()
  65.         if blockBelow == true then
  66.             if blockInfo.name == "minecraft:water" then
  67.                 turtle.down()
  68.                 selectBlock("minecraft:stonebrick")
  69.                 turtle.placeUp()
  70.             else
  71.                 break
  72.             end
  73.         end
  74.         turtle.down()
  75.         selectBlock("minecraft:stonebrick")
  76.         turtle.placeUp()
  77.     until blockBelow == true and blockInfo.name ~= "minecraft:water"
  78.     forwardDig()
  79.     for i = 1, 2 do
  80.         turtle.turnRight()
  81.     end
  82.     selectBlock("minecraft:stonebrick")
  83.     turtle.place()
  84.     repeat
  85.         blockAbove, blockInfo = turtle.inspectUp()
  86.         if blockAbove == false then
  87.             turtle.up()
  88.         elseif blockAbove == true then
  89.             if blockInfo.name ~= "minecraft:stone_brick_stairs" then
  90.                 upDig()
  91.             end
  92.         end
  93.     until blockInfo == "minecraft:stone_brick_stairs"
  94.     turtle.back()
  95.     for i = 1, 2 do
  96.         turtle.up()
  97.     end
  98. end
  99.  
  100. function placePillars()
  101.     placePillar()
  102.     turtle.turnRight()
  103.     for i = 1, 4 do
  104.         turtle.forward()
  105.     end
  106.     turtle.turnLeft()
  107.     placePillar()
  108.     turtle.turnLeft()
  109.     for i = 1, 4 do
  110.         turtle.forward()
  111.     end
  112.     turtle.turnRight()
  113. end
  114.  
  115. function placeTorch()
  116.     turtle.up()
  117.     turtle.turnRight()
  118.     for i = 1, 3 do
  119.         turtle.forward()
  120.     end
  121.     turtle.turnRight()
  122.     selectBlock("minecraft:torch")
  123.     turtle.place()
  124.     turtle.turnRight()
  125.     for i = 1, 3 do
  126.         turtle.forward()
  127.     end
  128.     turtle.turnRight()
  129.     turtle.down()
  130. end
  131.  
  132. function placeBridgeChunk()
  133.     for i = 1, 2 do
  134.         turtle.turnRight()
  135.     end
  136.     turtle.up()
  137.     selectBlock("minecraft:stonebrick")
  138.     if bridgePos % 2 == 0 then
  139.         turtle.up()
  140.         turtle.place()
  141.         turtle.down()
  142.     end
  143.     selectBlock("minecraft:stonebrick")
  144.     turtle.place()
  145.     turtle.down()
  146.     turtle.turnLeft()
  147.     for i = 1, 7 do
  148.         selectBlock("minecraft:stonebrick")
  149.         turtle.turnRight()
  150.         turtle.place()
  151.         turtle.turnLeft()
  152.         turtle.forward()
  153.     end
  154.     turtle.down()
  155.     for i = 1, 2 do
  156.         turtle.turnRight()
  157.     end
  158.     turtle.forward()
  159.     for i = 1, 2 do
  160.         turtle.up()
  161.     end
  162.     turtle.turnLeft()
  163.     selectBlock("minecraft:stonebrick")
  164.     turtle.place()
  165.     if bridgePos % 2 == 0 then
  166.         turtle.up()
  167.         selectBlock("minecraft:stonebrick")
  168.         turtle.place()
  169.         turtle.down()
  170.     end
  171.     for i = 1, 2 do
  172.         turtle.down()
  173.     end
  174.     turtle.turnRight()
  175.     turtle.forward()
  176.     for i = 1, 4 do
  177.         turtle.turnLeft()
  178.         selectBlock("minecraft:stonebrick")
  179.         turtle.place()
  180.         turtle.turnRight()
  181.         turtle.forward()
  182.     end
  183.     turtle.turnLeft()
  184.     selectBlock("minecraft:stonebrick")
  185.     turtle.place()
  186.     turtle.down()
  187.     selectBlock("minecraft:stonebrick")
  188.     turtle.place()
  189.     turtle.turnLeft()
  190.     for i = 1, 4 do
  191.         turtle.forward()
  192.     end
  193.     turtle.turnRight()
  194.     selectBlock("minecraft:stonebrick")
  195.     turtle.place()
  196.     if bridgePos % 6 == 0 then
  197.         placePillars()
  198.     end
  199.     turtle.turnRight()
  200.     for i = 1, 2 do
  201.         turtle.up()
  202.     end
  203.     for i = 1, 5 do
  204.         turtle.forward()
  205.     end
  206.     turtle.turnRight()
  207. end
  208.  
  209. function clearSpace()
  210.     turtle.turnRight()
  211.     for i = 1, 3 do
  212.         upDig()
  213.     end
  214.     for i = 1, 6 do
  215.         for j = 1, 6 do
  216.             forwardDig()
  217.         end
  218.         for j = 1, 2 do
  219.             turtle.turnRight()
  220.         end
  221.         downDig()
  222.     end
  223.     for i = 1, 3 do
  224.         turtle.up()
  225.     end
  226.     turtle.turnLeft()
  227. end
  228.  
  229. function buildChunkOfBridge()
  230.     forwardDig()
  231.     clearSpace()
  232.     placeBridgeChunk()
  233.     if bridgePos % 8 == 0 then
  234.         placeTorch()
  235.     end
  236.     bridgePos = bridgePos + 1
  237. end
  238.  
  239. function checkFuel()
  240.     fuelLevel = turtle.getFuelLevel()
  241.     if fuelLevel < 100 then
  242.         for i = 1, 16 do
  243.             turtle.select(i)
  244.             turtle.refuel(64)
  245.         end
  246.     end
  247.     if fuelLevel == 0 then
  248.         error("no fuel!")
  249.     end
  250. end
  251.  
  252. function mainLoop()
  253.    while true do
  254.        checkFuel()
  255.        buildChunkOfBridge()
  256.    end
  257. end
  258.  
  259. mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement