Hopfi

simple_mining_turtle_ftb

May 8th, 2021
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function digLevel(N)
  2.     level_done = false
  3.     rows_done = 0
  4.     while not level_done do
  5.         -- finish one row
  6.         for i=1,N-1,1 do
  7.             turtle.dig()
  8.             turtle.forward()
  9.         end
  10.         rows_done = rows_done + 1
  11.  
  12.         -- turn
  13.         turtle.turnLeft()
  14.         turtle.dig()
  15.         turtle.forward()
  16.         turtle.turnLeft()
  17.  
  18.         -- row back
  19.         for i=1,N-1,1 do
  20.             turtle.dig()
  21.             turtle.forward()
  22.         end
  23.         rows_done = rows_done + 1
  24.  
  25.         -- start a new level from current corner
  26.         if rows_done == N then
  27.             turtle.turnLeft()
  28.             rows_done = 0
  29.             level_done = true
  30.         else
  31.             turtle.turnRight()
  32.             turtle.dig()
  33.             turtle.forward()
  34.             turtle.turnRight()
  35.         end
  36.     end
  37. end
  38.  
  39.  
  40. turtle.refuel()
  41.  
  42. -- N % 2 should be 0
  43. N = 4
  44. target_depth = 3
  45.  
  46. depth = 0
  47.  
  48. turtle.digDown()
  49. turtle.down()
  50.  
  51. while depth < target_depth do
  52.     digLevel(N)
  53.     depth = depth + 1
  54.     turtle.digDown()
  55.     turtle.down()
  56. end
  57.  
  58. for i=1,depth+1,1 do
  59.     turtle.up()
  60. end
  61.  
  62.  
  63.  
  64.  
  65.  
RAW Paste Data