Advertisement
visiongaming43

Untitled

Sep 23rd, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. -- Get fuel level for turtle
  2.  
  3. local fuelLevel = turtle.getFuelLevel()
  4.  
  5. -- Ask user for length, width, and height of quarry ( rectangle )
  6.  
  7. print("Please enter the length of your quarry")
  8. local length = io.read()
  9.  
  10. print("Please enter the width of your quarry")
  11. local width = io.read()
  12.  
  13. print("Please enter how far you would like the quarry to go down")
  14. local height = io.read()
  15.  
  16. local function mine()
  17. turtle.dig()
  18. turtle.forward()
  19. end
  20.  
  21. -- Change it to false if you want turtle to go left instead of right
  22. local direction = true
  23.  
  24. local directionNew = direction
  25.  
  26. if(fuelLevel < (((length) * (width) * (height)) + 2 )) then
  27. print("You don't have enough fuel to run this code! Sorry!")
  28. else
  29. print("Success! You have enough fuel! Starting program now!")
  30.  
  31. for heightCounter = height, 1, -1
  32. do
  33. turtle.digDown()
  34. turtle.down()
  35.  
  36. for lengthCounter = length, 1, -1
  37. do
  38. direction = not(direction)
  39. mine()
  40.  
  41. if(direction) then
  42. turtle.turnLeft()
  43. else
  44. turtle.turnRight()
  45. end
  46.  
  47. for widthCounter = width, 1, -1
  48. do
  49. turtle.mine()
  50. end
  51.  
  52. if(direction) then
  53. turtle.turnLeft()
  54. else
  55. turtle.turnRight()
  56. end
  57. end
  58. turtle.dig()
  59. turtle.forward()
  60. turtle.turnRight()
  61. turtle.turnRight()
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement