DYankee

coal transfer

Jul 17th, 2021 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. chests = {
  2. "quark:oak_chest",
  3. "charm:oak_chest",
  4. }
  5. fuel = {
  6. "minecraft:coal_block",
  7. "actuallyadditions:block_misc",
  8. "quark:charcoal_block",
  9. "minecraft:charcoal"
  10. }
  11.  
  12. wood = {
  13. "byg:fir_log"
  14. }
  15.  
  16. function getFuelIndex()
  17. for slotNum = 1, 16, 1 do
  18. local Item = turtle.getItemDetail(slotNum)
  19. if(Item ~=nil) then
  20. for fuelIndex =1, #fuel, 1 do
  21. if(Item.name == fuel[fuelIndex]) then
  22. return slotNum
  23. end
  24. end
  25. end
  26. end
  27. end
  28.  
  29. function refuel()
  30. if(turtle.getFuelLevel() < 400) then
  31. local Index = getFuelIndex()
  32. if(Index ~= nil) then
  33. turtle.select(Index)
  34. turtle.refuel(2)
  35. end
  36. end
  37. end
  38.  
  39. function getCoalIndex()
  40. for slotNum = 1, 16, 1 do
  41. local item = turtle.getItemDetail(slotNum)
  42. if(item ~= nil) then
  43. if(item.name == "minecraft:charcoal") then
  44. return slotNum
  45. end
  46. end
  47. end
  48. end
  49.  
  50. function getCoalCount()
  51. coalCount = 0
  52. for slotNum = 1,16,1 do
  53. local whatsHere = turtle.getItemDetail(slotNum)
  54. if(whatsHere ~= nil) then
  55. if (whatsHere.name == "minecraft:charcoal") then
  56. turtle.select(slotNum)
  57. coalCount = coalCount + turtle.getItemCount()
  58. print("Current coal Count A-",coalCount)
  59. end
  60. end
  61. end
  62. print("Current coal Count B-",coalCount)
  63. end
  64.  
  65. function dropCoal()
  66. getCoalCount()
  67. for slotNum = 1, 16, 1 do
  68. local item = turtle.getItemDetail(slotNum)
  69. if(item ~= nil) then
  70. if(item.name == "minecraft:charcoal") then
  71. print("Droppign - " .. item.name)
  72. turtle.select(slotNum)
  73. turtle.dropDown()
  74. end
  75. end
  76. end
  77. end
  78.  
  79. function fillCraftingGrid()
  80. turtle.select(1)
  81. turtle.suckDown(coalCount / 9)
  82. turtle.select(2)
  83. turtle.suckDown(coalCount / 9)
  84. turtle.select(3)
  85. turtle.suckDown(coalCount / 9)
  86. turtle.select(5)
  87. turtle.suckDown(coalCount / 9)
  88. turtle.select(6)
  89. turtle.suckDown(coalCount / 9)
  90. turtle.select(7)
  91. turtle.suckDown(coalCount / 9)
  92. turtle.select(9)
  93. turtle.suckDown(coalCount / 9)
  94. turtle.select(10)
  95. turtle.suckDown(coalCount / 9)
  96. turtle.select(11)
  97. turtle.suckDown(coalCount / 9)
  98. end
  99.  
  100. function getCoal()
  101. for i = 1, 5, 1 do
  102. turtle.suckUp()
  103. turtle.dropUp()
  104. turtle.forward()
  105. end
  106. end
  107.  
  108. while true do
  109. getCoal()
  110. dropCoal()
  111. fillCraftingGrid()
  112. turtle.craft()
  113. refuel()
  114. if getFuelIndex ~= nil then
  115. turtle.select(getFuelIndex())
  116. turtle.dropUp(1)
  117. turtle.drop()
  118. end
  119. turtle.suckDown()
  120. turtle.turnLeft()
  121. turtle.turnLeft()
  122. for i = 1, 5, 1 do
  123. turtle.forward()
  124. end
  125. turtle.turnLeft()
  126. turtle.turnLeft()
  127. sleep(600)
  128. end
Add Comment
Please, Sign In to add comment