Advertisement
OttomateN

Quarry

Jul 15th, 2022 (edited)
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. function diga()
  2.     turtle.dig()
  3.     turtle.digUp()
  4.     turtle.digDown()
  5. end
  6.  
  7. io.write('What length and width would you like your quarry to be?\n')
  8. local stepsLI = io.read()
  9. local stepsL = stepsLI
  10. local stepsWI = io.read()
  11. local stepsW = stepsWI
  12.  
  13. local toTurn = stepsL - 1
  14.  
  15. io.write('How many levels would you like to go?\n')
  16. local levelI = io.read() / 3
  17. local level = math.floor(levelI)
  18.  
  19. local count = 0
  20.  
  21. for f = 1, level, 1 do
  22.     for g = 1, 2, 1 do
  23.         turtle.digDown()
  24.         turtle.down()
  25.     end
  26.  
  27.     for h = 1, stepsL, 1 do
  28.         for i = 1, stepsW - 1, 1 do
  29.             while(turtle.detect() or turtle.detectUp() or turtle.detectDown()) do
  30.                 diga()
  31.             end
  32.             turtle.forward()
  33.         end
  34.         count = count + 1
  35.         if(toTurn ~= 0) then
  36.             if(count % 2 == 0) then
  37.                 turtle.turnLeft()
  38.                 if(turtle.detect() or turtle.detectUp() or turtle.detectDown()) then
  39.                     diga()
  40.                 end
  41.                 turtle.forward()
  42.                 turtle.turnLeft()
  43.             else
  44.                 turtle.turnRight()
  45.                 if(turtle.detect() or turtle.detectUp() or turtle.detectDown()) then
  46.                     diga()
  47.                 end
  48.                 turtle.forward()
  49.                 turtle.turnRight()
  50.             end
  51.             toTurn = toTurn - 1
  52.             io.write(toTurn)
  53.         end
  54.     end
  55.     turtle.digUp()
  56.     if(count % 2 == 0) then
  57.         turtle.turnRight()
  58.     else
  59.         turtle.turnLeft()
  60.     end
  61.     turtle.digDown()
  62.     turtle.down()
  63.     stepsL = stepsLI
  64.     stepsW = stepsWI
  65.     toTurn = stepsL - 1
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement