DanielBoling

Tunnel (New)

Dec 2nd, 2020 (edited)
993
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function main()
  2.     for q = 1,150 do
  3.         dig()
  4.         turtle.digDown()
  5.         digUp()
  6.         turtle.down()
  7.         checkBlocks('down')
  8.         unmove()
  9.         turtle.turnLeft()
  10.         checkBlocks('front')
  11.         unmove()
  12.         turtle.turnRight()
  13.         turtle.turnRight()
  14.         checkBlocks('front')
  15.         unmove()
  16.         turtle.up()
  17.         checkBlocks('front')
  18.         unmove()
  19.         turtle.up()
  20.         checkBlocks('front')
  21.         unmove()
  22.         turtle.turnLeft()
  23.         checkBlocks('down')
  24.         unmove()
  25.         turtle.turnLeft()
  26.         checkBlocks('up')
  27.         unmove()
  28.         turtle.down()
  29.         checkBlocks('front')
  30.         unmove()
  31.         turtle.turnRight()    
  32.         turtle.forward()
  33.     end
  34.     turtle.turnRight()
  35.     turtle.turnRight()
  36.     for w = 1,150 do
  37.         turtle.forward()
  38.     end
  39. end
  40.  
  41. moves = {}
  42.  
  43. function checkBlocks(side)
  44.     key, dataDown = turtle.inspectDown()
  45.     key, dataUp = turtle.inspectUp()
  46.     key, data = turtle.inspect()
  47.     blocks = {'minecraft:gold_ore', 'minecraft:iron_ore', 'minecraft:coal_ore', 'minecraft:lapis_ore', 'minecraft:diamond_ore', 'minecraft:redstone_ore', 'minecraft:emerald_ore', 'mekanism:copper_ore', 'mekanism:tin_ore', 'mekanism:osmium_ore', 'mekanism:uranium_ore', 'mekanism:lead_ore', 'powah:uraninite_ore_poor', 'powah:uraninite_ore', 'powah:uraninite_ore_dense', 'immersiveengineering:ore_copper', 'immersiveengineering:ore_aluminum', 'immersiveengineering:ore_lead', 'immersiveengineering:ore_silver', 'immersiveengineering:ore_nickel'}
  48.     if side == 'down' then
  49.         for i = 1,#blocks do
  50.             if dataDown.name == blocks[i] then
  51.                 turtle.digDown()
  52.                 turtle.down()
  53.                 addMove('down')
  54.                 checkBlocks('down')
  55.             end
  56.         end
  57.     elseif side == 'front' then
  58.         for i = 1,#blocks do
  59.             if data.name == blocks[i] then
  60.                 dig()
  61.                 turtle.forward()
  62.                 addMove('forward')
  63.                 checkBlocks('front')
  64.             end
  65.         end
  66.     elseif side == 'up' then
  67.         for i = 1,#blocks do
  68.             if dataUp.name == blocks[i] then
  69.                 digUp()
  70.                 turtle.up()
  71.                 addMove('up')
  72.                 checkBlocks('up')
  73.             end
  74.         end
  75.     end
  76. end
  77.  
  78. function addMove(side)
  79.     table.insert(moves, side)
  80. end
  81.  
  82. function unmove()
  83.     if #moves > 0 then
  84.         for e = 1,#moves do
  85.             if moves[1] == 'down' then
  86.                 turtle.up()
  87.             elseif moves[1] == 'up' then
  88.                 turtle.down()
  89.             elseif moves[1] == 'forward' then
  90.                 turtle.back()
  91.             elseif moves[1] == 'left' then
  92.                 turtle.turnRight()
  93.             elseif moves[1] == 'right' then
  94.                 turtle.turnLeft()
  95.             end
  96.             table.remove(moves)
  97.         end
  98.     else
  99.         return
  100.     end
  101. end
  102.  
  103. function digUp()
  104.     while turtle.detectUp() do
  105.         turtle.digUp()
  106.         sleep(.5)
  107.     end
  108. end
  109.  
  110. function dig()
  111.     while turtle.detect() do
  112.         turtle.dig()
  113.         sleep(.5)
  114.     end
  115. end
  116.  
  117. main()
  118.  
RAW Paste Data