Advertisement
sosochka

turtleStripMine JSZFGG8b

Jun 16th, 2022 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. local function findFuel()
  2. for i=1, 16 do
  3. turtle.select(i)
  4. local itemDetails = turtle.getItemDetail()
  5. if itemDetails ~= nil then
  6. if itemDetails.name == "minecraft:coal" then
  7. turtle.refuel()
  8. break
  9. end
  10. end
  11. end
  12. turtle.select(1)
  13. end
  14.  
  15. local function findAndPlaceTorch()
  16. if counter ~= 6 then
  17. counter = counter + 1
  18. return
  19. end
  20. counter = 1
  21. for i=1, 16 do
  22. turtle.select(i)
  23. local itemDetails = turtle.getItemDetail()
  24. if itemDetails ~= nil then
  25. if itemDetails.name == "minecraft:torch" then
  26. turtle.placeDown()
  27. break
  28. end
  29. end
  30. end
  31. turtle.select(1)
  32. end
  33.  
  34. local function cleanInventory()
  35. local blocksToClean = {
  36. "minecraft:cobblestone",
  37. "minecraft:deepslate",
  38. "minecraft:cobbled_deepslate",
  39. "minecraft:granite",
  40. "minecraft:diorite",
  41. "minecraft:gravel",
  42. "minecraft:dirt",
  43. "indreb:uranium_ore",
  44. "mekanism:uranium_ore",
  45. "minecraft:calcite",
  46. "minecraft:amethyst_block",
  47. "minecraft:tuff"
  48. }
  49. for i=1, 16 do
  50. turtle.select(i)
  51. local itemDetails = turtle.getItemDetail()
  52. if itemDetails ~= nil then
  53. for i=1,#blocksToClean do
  54. if itemDetails.name == blocksToClean[i] then
  55. turtle.dropDown()
  56. break
  57. end
  58. end
  59. end
  60. end
  61. turtle.select(1)
  62. end
  63.  
  64. local useTorches = false
  65. counter = 1
  66.  
  67. term.clear()
  68. term.setCursorPos(1, 1)
  69. print("Do I need to place torches?[y/n]")
  70. local input = io.read()
  71. if input == "y" then
  72. useTorches = true
  73. end
  74.  
  75. while true do
  76. --Fuel logic
  77. while turtle.getFuelLevel() == 0 do
  78. findFuel()
  79. end
  80. if turtle.getFuelLevel() <= 10 then
  81. findFuel()
  82. end
  83.  
  84. --Fuel main digging and torch if specified
  85. turtle.dig()
  86. turtle.forward()
  87. turtle.digUp()
  88. turtle.digDown()
  89. if useTorches then
  90. findAndPlaceTorch()
  91. end
  92.  
  93. --Fuel ouput
  94. term.clear()
  95. term.setCursorPos(1, 1)
  96. print("Fuel level: " .. turtle.getFuelLevel())
  97.  
  98. --Cleaing inventory logic
  99. cleanInventory()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement