adamg765

newTunnel

Jun 19th, 2017
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = { ... }
  2. local distance = tonumber(args[1])
  3. local torches = 2
  4. local cobblestone = 3
  5.  
  6. local function refuel()
  7.     if turtle.getFuelLevel() == 0 then
  8.         local prev = turtle.getSelectedSlot()
  9.         turtle.select(1)
  10.         if not turtle.refuel(1) then
  11.             print('Need more fuel')
  12.             while not turtle.refuel(1) do
  13.                 sleep(1)
  14.             end
  15.         end
  16.         turtle.select(prev)
  17.     end
  18. end
  19.  
  20. local function tryForwards()
  21.     refuel()
  22.     while not turtle.forward() do
  23.         if turtle.detect() then
  24.             turtle.dig()
  25.         end
  26.         sleep(0.5)
  27.     end
  28. end
  29.  
  30. local function tryDown()
  31.     refuel()
  32.     while not turtle.down() do
  33.         if turtle.detectDown() then
  34.             turtle.digDown()
  35.         end
  36.         sleep(0.5)
  37.     end
  38. end
  39.  
  40. local function tryUp()
  41.     refuel()
  42.     while not turtle.up() do
  43.         if turtle.detectUp() then
  44.             turtle.digUp()
  45.         end
  46.         sleep(0.5)
  47.     end
  48. end
  49.  
  50. local function placeTorch()
  51.     local prev = turtle.getSelectedSlot()
  52.     turtle.select(torches)
  53.     turtle.place()
  54.     turtle.select(prev)
  55. end
  56.  
  57. local function placeBlock()
  58.     local prev = turtle.getSelectedSlot()
  59.     turtle.select(cobblestone)
  60.     turtle.placeDown()
  61.     turtle.select(prev)
  62. end
  63.  
  64.  
  65. local function clearSection(currDistance)
  66.     tryForwards()
  67.  
  68.     if not turtle.detectDown() then
  69.         placeBlock()
  70.     end
  71.  
  72.     if currDistance % 6 == 0 then
  73.         turtle.turnRight()
  74.         turtle.turnRight()
  75.         placeTorch()
  76.         turtle.turnRight()
  77.         turtle.turnRight()
  78.     end
  79.     tryUp()
  80.     turtle.turnLeft()
  81.    
  82.     tryForwards()
  83.     turtle.turnLeft()
  84.  
  85.     tryForwards()
  86.     tryForwards()
  87.     tryDown()
  88.     turtle.turnRight()
  89.     turtle.turnRight()
  90.  
  91.     if not turtle.detectDown() then
  92.         placeBlock()
  93.     end
  94.  
  95.     tryForwards()
  96.  
  97.     if not turtle.detectDown() then
  98.         placeBlock()
  99.     end
  100.  
  101. end
  102.  
  103. turtle.select(1)
  104.  
  105. turtle.turnRight()
  106.  
  107. for i = 1, distance, 1 do
  108.     clearSection(i)
  109. end
  110. turtle.dig()
  111. turtle.turnRight()
  112. turtle.up()
  113. for i = 1, distance, 1 do
  114.     tryForwards()
  115. end
  116. tryDown()
  117. for i = 3, 16, 1 do
  118.     turtle.select(i)
  119.     turtle.drop()
  120. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×