Advertisement
Sir_Popsilots

3x3 turtle tunnel

Oct 6th, 2022 (edited)
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local Arg = {...}
  2.  
  3. local function getBlockName()
  4.     local isThere , blockInfo = turtle.inspect()
  5.     if isThere then
  6.         return blockInfo.name
  7.     end
  8.     return "air"
  9. end
  10.  
  11. local function getBlockNameUp()
  12.     local isThere , blockInfo = turtle.inspectUp()
  13.     if isThere then
  14.         return blockInfo.name
  15.     end
  16.     return "air"
  17. end
  18.  
  19. local function checkIfMineble(blockname)
  20.     print("im looking at ", blockname)
  21.     if string.lower(blockname) == "minecraft:bedrock" then
  22.         return false
  23.     end
  24.     return true
  25. end
  26.  
  27. local function tryDigUntilClear()
  28.     if checkIfMineble(getBlockName()) then
  29.         while turtle.detect() do
  30.             turtle.dig()
  31.         end
  32.     end
  33. end
  34.  
  35. local function tryDigUpUntilClear()
  36.     if checkIfMineble(getBlockNameUp()) then
  37.         while turtle.detectUp() do
  38.             turtle.digUp()
  39.         end
  40.     end
  41. end
  42.  
  43. local tunnellenght = Arg[1]
  44.  
  45. while tunnellenght ~= 0 do
  46.     tryDigUntilClear()
  47.     turtle.forward()
  48.     turtle.turnRight()
  49.     for i =1 , 2 ,1 do
  50.         tryDigUntilClear()
  51.         tryDigUpUntilClear()
  52.         turtle.up()
  53.     end
  54.     tryDigUntilClear()
  55.     turtle.turnLeft()
  56.     turtle.turnLeft()
  57.     for i =1 , 2 ,1 do
  58.         tryDigUntilClear()
  59.         turtle.down()
  60.     end
  61.     tryDigUntilClear()
  62.     turtle.turnRight()
  63.     tunnellenght = tunnellenght - 1
  64. end
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement