Advertisement
Fatherless

mineDown

Dec 7th, 2024 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. -- Functions
  2.  
  3. local function fwd()
  4.     while not turtle.forward() do
  5.         turtle.dig()
  6.     end
  7. end
  8.  
  9. local function dwn() -- probably not necessary
  10.     while not turtle.down() do
  11.         turtle.digDown()
  12.     end
  13. end
  14.  
  15. local function betterDig()
  16.     while turtle.detect() do
  17.         turtle.dig()
  18.     end
  19. end
  20.  
  21. local function fwdRow()
  22.     fwd()
  23.  
  24.     turtle.turnRight()
  25.    
  26.     betterDig()
  27.  
  28.     turtle.turnLeft()
  29.     turtle.turnLeft()
  30.  
  31.     betterDig()
  32.  
  33.     turtle.turnRight()
  34. end
  35.  
  36. local function dwnRow()
  37.     dwn()
  38.  
  39.     turtle.turnRight()
  40.  
  41.     betterDig()
  42.  
  43.     turtle.turnLeft()
  44.     turtle.turnLeft()
  45.  
  46.     betterDig()
  47.  
  48.     turtle.turnRight()
  49. end
  50.  
  51. local function clearFace()
  52.     for i = 1, 4 do
  53.         turtle.up()
  54.     end
  55.     fwdRow()
  56.     for i = 1, 5 do
  57.         dwnRow()
  58.     end
  59. end
  60.  
  61. local function climb()
  62.     turtle.up()
  63.     fwd()
  64. end
  65.  
  66. -- Main
  67.  
  68. print("How deep?")
  69. local d = read()
  70.  
  71. -- TODO: Fuel check
  72. -- Fuel per level is 36
  73.  
  74. if turtle.getFuelLevel() < d * 36 then
  75.     print("I need at least ".. (d * 36) .. " levels of fuel for that")
  76. end
  77.  
  78.  
  79. for i = 1, d do
  80.     clearFace()
  81. end
  82.  
  83. turtle.turnRight()
  84. turtle.turnRight()
  85.  
  86. for i = 1, d do
  87.     climb()
  88. end
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement