HaizelNut

Untitled

Jan 4th, 2024
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | Gaming | 0 0
  1. --Program for a Quarry
  2.  
  3. --Clearing Console
  4.  
  5. function clearConsole()
  6. term.clear()
  7. term.setCursorPos(1, 1)
  8. end
  9.  
  10. --Refueling
  11.  
  12. function checkFuel()
  13. local fuelLevel = turtle.getFuelLevel()
  14. if fuelLevel == "unlimited" or fuelLevel > 10 then
  15. return
  16. end
  17.  
  18. clearConsole()
  19. print("Low on fuel - Refueling")
  20.  
  21. --Refuel from Inventory
  22.  
  23. for slot = 1, 16 do
  24. turtle.select(slot)
  25. if turtle.getFuelLimit() then
  26. break
  27. end
  28. end
  29.  
  30. turtle.select(1) --Select default slot
  31. end
  32.  
  33. --Quarry Area
  34.  
  35. function quarry(length, width)
  36. for i = 1, length do
  37. for j = 1, width do
  38. checkFuel() --Check before movement
  39. turtle.dig()
  40. turtle.forward()
  41. end
  42.  
  43. if i < length then
  44. if i % 2 == 1 then
  45. turtle.turnRight()
  46. checkFuel()
  47. turtle.dig()
  48. turtle.forward()
  49. turtle.turnRight()
  50. else
  51. turtle.turnLeft()
  52. checkFuel()
  53. turtle.dig()
  54. turtle.forward()
  55. turnLeft()
  56. end
  57. end
  58. end
  59. end
  60.  
  61. --Inventory emptying
  62.  
  63. function ClearInventory()
  64. clearConsole()
  65. checkFuel()
  66. turtle.turnLeft()
  67. turtle.turnLeft() --Rotating to Place Chest
  68.  
  69. turtle.select(2)
  70. turtle.place()
  71. for slot = 3, 16 do
  72. turtle.select(slot)
  73. turtle.drop()
  74. end
  75. turtle.select(1)
  76. turtle.turnRight()
  77. turtle.turnRight()
  78. end
  79.  
  80. --Interface
  81.  
  82. clearConsole()
  83. print("Mining Program")
  84. print("--------------")
  85. clearConsole()
  86.  
  87. --Width, Length
  88.  
  89. write("Width ?: ")
  90. local width = tonumber(read())
  91.  
  92. write("Length ?: ")
  93. local lenght = tonumber(read())
  94.  
  95. --Quarry Area
  96.  
  97. quarry(lenght, width)
  98.  
  99. print("Completed Task")
Advertisement
Add Comment
Please, Sign In to add comment