Plieax

coalmover

Apr 27th, 2024 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. local function left()
  2. turtle.turnLeft()
  3. if turtle.detect() then
  4. --turtle.dig()
  5. end
  6. turtle.forward()
  7. turtle.turnRight()
  8. end
  9.  
  10. local function right()
  11. turtle.turnRight()
  12. if turtle.detect() then
  13. --turtle.dig()
  14. end
  15. turtle.forward()
  16. turtle.turnLeft()
  17. end
  18.  
  19. local function forward()
  20. if turtle.detect() then
  21. turtle.dig()
  22. end
  23. turtle.forward()
  24. end
  25.  
  26. local function back()
  27. turtle.back()
  28. end
  29.  
  30. local function up()
  31. if turtle.detectUp() then
  32. turtle.digUp()
  33. end
  34. turtle.up()
  35. end
  36.  
  37. local function down()
  38. turtle.down()
  39. end
  40.  
  41. local atHopper = true
  42.  
  43. while true do
  44. -- take items from hopper
  45. if atHopper then
  46. for i=1,6 do
  47. turtle.suck()
  48. select(i+1)
  49. end
  50. end
  51.  
  52. turtle.select(1)
  53.  
  54.  
  55. --get total amount of coal
  56. local count = 0
  57. for i=1, 16 do
  58. local item = turtle.getItemDetail(i)
  59. if item then
  60. count = count + item.count
  61. end
  62. end
  63.  
  64.  
  65.  
  66. if count >= 32 then
  67. --refuel
  68. atHopper = false
  69. count = count -2
  70. turtle.select(1)
  71. turtle.refuel(1)
  72.  
  73.  
  74. -- go to chest to distribute
  75. left()
  76. left()
  77. left()
  78. up()
  79. forward()
  80.  
  81. -- distribute to chest
  82. for i=1,6 do
  83. turtle.select(i)
  84. turtle.drop(64)
  85. end
  86.  
  87. --go back to hopper
  88. back()
  89. down()
  90. right()
  91. right()
  92. right()
  93. sleep(120)
  94. atHopper = true
  95. select(1)
  96. turtle.drop(2)
  97. end
  98. end
  99.  
  100.  
Advertisement
Add Comment
Please, Sign In to add comment