JustJurt

Dig Area Outdated

Jul 20th, 2024 (edited)
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 KB | Software | 0 0
  1.  
  2. local depth = 0
  3. local width = 0
  4. local height = 0
  5. local total = 0
  6. local progress = 0
  7. local layersLeft = 0
  8.  
  9. local function progressUpdate()
  10.     progress = progress + 1
  11.     term.clear()
  12.     term.setCursorPos(1,2)
  13.     write('Operation progress: ')
  14.     write(math.floor((progress/total)*1000)/10)
  15.     write('%\nLayers left to mine: ')
  16.     write(layersLeft)
  17.     write('%\nBlocks left to mine: ')
  18.     write(total-progress)
  19. end
  20.  
  21. local function isFallingBlock(direction)
  22.     local success = false
  23.     if direction == "forward" then success = turtle.detect() end
  24.     if direction == "up" then success = turtle.detectUp() end
  25.     if direction == "down" then success = turtle.detectDown() end
  26.     if success then
  27.         return true
  28.     end
  29.     return false
  30. end
  31.  
  32. local function dig(direction)
  33.     if direction == "forward" then turtle.dig() end
  34.     if direction == "up" then turtle.digUp() end
  35.     if direction == "down" then turtle.digDown() end
  36.     while isFallingBlock(direction) do
  37.         if direction == "forward" then turtle.dig() end
  38.         if direction == "up" then turtle.digUp() end
  39.         if direction == "down" then turtle.digDown() end
  40.     end
  41.     progressUpdate()
  42. end
  43.  
  44. local function Excavate()
  45.     local atTop = false
  46.     local atRight = false
  47.     for z = 1, depth, 1 do
  48.         layersLeft = depth - z
  49.         dig("forward")
  50.         turtle.forward()
  51.         if atRight then
  52.             turtle.turnLeft()
  53.         else
  54.             turtle.turnRight()
  55.         end
  56.         for y = 1, height, 1 do
  57.             for x = 1, width - 1, 1 do
  58.                 dig("forward")
  59.                 turtle.forward()
  60.             end
  61.             height = height + 0
  62.             if y < height then
  63.                 if atTop then
  64.                     dig("down")
  65.                     turtle.down()
  66.                 else
  67.                     dig("up")
  68.                     turtle.up()
  69.                 end
  70.                 turtle.turnRight()
  71.                 turtle.turnRight()
  72.             end
  73.             atRight = not atRight
  74.         end
  75.         if atRight then
  76.             turtle.turnLeft()
  77.         else
  78.             turtle.turnRight()
  79.         end
  80.         atTop = not atTop
  81.     end
  82. end
  83.  
  84. term.clear()
  85. term.setCursorPos(1,2)
  86. print('[EXCAVATOR] <Outdated method>')
  87. print('! Support for this script may be limited !')
  88. write('Depth: ')
  89. depth = read()
  90. write('Width: ')
  91. width = read()
  92. write('Height: ')
  93. height = read()
  94. write('Total blocks to mine: ')
  95. total = width*height*depth
  96. print(total)
  97. write('Type "yes" to confirm: ')
  98. local confirm = read()
  99. term.clear()
  100. term.setCursorPos(1,2)
  101. if confirm == "yes" then
  102.     Excavate()
  103.     term.clear()
  104.     term.setCursorPos(1,2)
  105.     write('Operation complete.\n')
  106. else
  107.     write('Operation canceled\n')
  108. end
  109.  
Advertisement
Add Comment
Please, Sign In to add comment