Advertisement
vxste

RefuelBot

Oct 9th, 2024 (edited)
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. local function turnLeft(Times)
  2. Times = Times or 1
  3. for _ = 1, Times do
  4. turtle.turnLeft()
  5. end
  6. end
  7.  
  8. local function turnRight(Times)
  9. Times = Times or 1
  10. for _ = 1, Times do
  11. turtle.turnRight()
  12. end
  13. end
  14.  
  15. local function DigAndCollect(Side)
  16. Side = not Side and "f" or string.lower(Side)
  17. if Side == "f" then
  18. turtle.dig()
  19. elseif Side == "l" then
  20. turnLeft()
  21. turtle.dig()
  22. elseif Side == "r" then
  23. turnRight()
  24. turtle.dig()
  25. turnLeft()
  26. elseif Side == "b" then
  27. turnLeft(2)
  28. turtle.dig()
  29. turnLeft(2)
  30. elseif Side == "u" then
  31. turtle.digUp()
  32. turtle.suckUp()
  33. return;
  34. elseif Side == "d" then
  35. turtle.digDown()
  36. turtle.suckDown()
  37. return;
  38. end
  39. turtle.suck()
  40. end
  41.  
  42. local Distance = 0;
  43.  
  44. while true do
  45. if Distance == 100 then
  46. DigAndCollect("l")
  47. turtle.forward()
  48. turnLeft()
  49. end
  50.  
  51. turtle.suck()
  52. turtle.suckUp()
  53. if turtle.detectUp() then
  54. DigAndCollect("u")
  55. end
  56. if turtle.detect() then
  57. DigAndCollect("f")
  58. end
  59. turtle.forward()
  60.  
  61. if not turtle.detectDown() then
  62. pcall(turtle.placeDown)
  63. end
  64.  
  65. for i = 1, math.huge do
  66. local Success, Result = pcall(turtle.getItemDetail, i)
  67. if not Success then
  68. break;
  69. end
  70.  
  71. if Result and Result.name ~= "minecraft:coal" then
  72. turtle.select(i)
  73. turtle.dropUp(64)
  74. elseif Result and Result.name == "minecraft:coal" then
  75. turtle.select(i)
  76. turtle.refuel()
  77. end
  78. end
  79.  
  80. Distance = Distance + 1
  81. print("Block #" .. tostring(Distance))
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement