Advertisement
visiongaming43

Untitled

Sep 23rd, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 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. do
  18. turtle.dig()
  19. turtle.forward()
  20. end
  21.  
  22. -- Change it to false if you want turtle to go left instead of right
  23. local direction = true
  24.  
  25. local directionNew = direction
  26.  
  27. if(fuelLevel < (((length) * (width) * (height)) + 2 )) then
  28. print("You don't have enough fuel to run this code! Sorry!")
  29. else
  30. print("Success! You have enough fuel! Starting program now!")
  31.  
  32. for heightCounter = height, 1, -1
  33. do
  34. turtle.digDown()
  35. turtle.down()
  36.  
  37. for lengthCounter = length, 1, -1
  38. do
  39. direction = not(direction)
  40. mine()
  41.  
  42. if(direction) then
  43. turtle.turnLeft()
  44. else
  45. turtle.turnRight()
  46. end
  47.  
  48. for widthCounter = width, 1, -1
  49. do
  50. turtle.mine()
  51. end
  52.  
  53. if(direction) then
  54. turtle.turnLeft()
  55. else
  56. turtle.turnRight()
  57. end
  58. end
  59. turtle.dig()
  60. turtle.forward()
  61. turtle.turnRight()
  62. turtle.turnRight()
  63. end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement