Advertisement
Fatherless

quarry

Dec 11th, 2024 (edited)
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. --[[
  2.  
  3.     This program tells the turtle to dig a quarry with specific dimensions
  4.     x is the horizontal space to the right of the turtle plus the block in front
  5.     y is the depth of the quarry
  6.     z is the space in front of the turtle
  7.  
  8. ]]
  9.  
  10. --[[ Functions ]]
  11.  
  12. -- Breaks a 3 block tall column in front of the turtle and moves forward 1
  13. local function fwdThree()
  14.     while not turtle.forward() do
  15.         turtle.dig()
  16.     end
  17.     turtle.digUp()
  18.     turtle.digDown()
  19. end
  20.  
  21. local function fwd()
  22.     while not turtle.forward() do
  23.         turtle.dig()
  24.     end
  25. end
  26.  
  27. local function dwn()
  28.     while not turtle.down() do
  29.         turtle.digDown()
  30.     end
  31. end
  32.  
  33. local function up()
  34.     while not turtle.up() do
  35.         turtle.digUp()
  36.     end
  37. end
  38.  
  39. local function enoughFuel(x, y, z)
  40.     return true
  41. end
  42.  
  43. --[[ Main ]]
  44.  
  45. -- Ask for dimensions
  46. print("How much in front of me? (z)")
  47. local z = read()
  48. print("How much horizontal space? (x)")
  49. local x = read()
  50. print("How deep? (y)")
  51. local y = read()
  52.  
  53. -- Check fuel
  54. if not enoughFuel(x, y, z) then
  55.     print("Please refuel")
  56. end
  57.  
  58. -- Dig
  59. fwd() -- Move into quarry space
  60. up()
  61.  
  62. local y_threes = y / 3
  63. local y_remainder = y % 3
  64.  
  65. for i = 1, y_threes do
  66.     dwn()
  67.     dwn()
  68.     dwn()
  69.     turtle.digDown()
  70.  
  71.     -- Dig out layer
  72.     for k = 1, x - 1 do
  73.         for j = 1, z - 1 do
  74.             fwdThree()
  75.         end
  76.         for j = 1, z - 1 do
  77.             turtle.back()
  78.         end
  79.         turtle.turnRight()
  80.         fwdThree()
  81.         turtle.turnLeft()
  82.     end
  83.     for j = 1, z - 1 do
  84.         fwdThree()
  85.     end
  86.     for j = 1, z - 1 do
  87.         turtle.back()
  88.     end
  89.     turtle.turnLeft()
  90.     for k = 1, x - 1 do
  91.         fwd()
  92.     end
  93.     turtle.turnRight()
  94. end
  95.  
  96. for i = 1, y_remainder do
  97.     dwn()
  98. end
  99. turtle.digDown()
  100.  
  101. -- Dig out layer
  102. for k = 1, x - 1 do
  103.     for j = 1, z - 1 do
  104.         fwdThree()
  105.     end
  106.     for j = 1, z - 1 do
  107.         turtle.back()
  108.     end
  109.     turtle.turnRight()
  110.     fwdThree()
  111.     turtle.turnLeft()
  112. end
  113. for j = 1, z - 1 do
  114.     fwdThree()
  115. end
  116. for j = 1, z - 1 do
  117.     turtle.back()
  118. end
  119. turtle.turnLeft()
  120. for k = 1, x - 1 do
  121.     fwd()
  122. end
  123. turtle.turnRight()
  124.  
  125. for i = 1, y - 1 do
  126.     up()
  127. end
  128. turtle.back()
  129.  
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement