Advertisement
DYankee

Wood Transfer

Jul 14th, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.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. }
  10.  
  11. wood = {
  12. "byg:fir_log"
  13. }
  14.  
  15. furnaceCount = 5
  16. checkedSlots = 1
  17.  
  18. function getFuel()
  19. isBlock, data = turtle.inspectDown()
  20. if (data.name == "charm:oak_chest") then
  21. fuelSlot = getFuelIndex()
  22. if fuelSlot ~= nil then
  23. turtle.select(fuelSlot)
  24. local coalBlocks = turtle.getItemCount()
  25. if coalBlocks <= 30 then
  26. turtle.suckDown(20)
  27. end
  28. elseif fuelSlot == nil then
  29. turtle.suckDown(30)
  30. end
  31. refuel()
  32. end
  33. end
  34.  
  35. function getFuelIndex()
  36. for slotNum = 1, 16, 1 do
  37. local Item = turtle.getItemDetail(slotNum)
  38. if(Item ~=nil) then
  39. for fuelIndex =1, #fuel, 1 do
  40. if(Item.name == fuel[fuelIndex]) then
  41. return slotNum
  42. end
  43. end
  44. end
  45. end
  46. end
  47.  
  48. function refuel()
  49. if(turtle.getFuelLevel() < 400) then
  50. local Index = getFuelIndex()
  51. if(Index ~= nil) then
  52. turtle.select(Index)
  53. turtle.refuel(2)
  54. end
  55. end
  56. end
  57.  
  58. function getWood()
  59. turtle.select(1)
  60. local currentWood = getWoodCount()
  61. while currentWood < furnaceCount * 64 + 30 do
  62. local currentWood2 = currentWood
  63. turtle.suckDown()
  64. currentWood = getWoodCount()
  65. if currentWood2 == currentWood then
  66. sleep(100)
  67. end
  68. end
  69. end
  70.  
  71. function getWoodIndex()
  72. for slotNum = 1, 16, 1 do
  73. local item = turtle.getItemDetail(slotNum)
  74. if(item ~= nil) then
  75. for woodIndex = 1, #wood, 1 do
  76. if(item.name == wood[woodIndex]) then
  77. return slotNum
  78. end
  79. end
  80. end
  81. end
  82. end
  83.  
  84. function getWoodCount()
  85. woodCount = 0
  86. for slotNum = 1,16,1 do
  87. local whatsHere = turtle.getItemDetail(slotNum)
  88. if(whatsHere ~= nil) then
  89. if (whatsHere.name == "byg:fir_log") then
  90. turtle.select(slotNum)
  91. woodCount = woodCount + turtle.getItemCount()
  92. print("Current wood Count A-",woodCount)
  93. end
  94. end
  95. end
  96. print("Current wood Count B-",woodCount)
  97. return woodCount
  98. end
  99.  
  100. function depositWood()
  101. for i = 1, furnaceCount, 1 do
  102. turtle.select(getWoodIndex())
  103. if turtle.getItemCount() < 64 then
  104. local amountDropped = turtle.getItemCount()
  105. turtle.dropDown(64)
  106. print("dropping -",amountDropped)
  107. turtle.select(getWoodIndex())
  108. turtle.dropDown(64 - amountDropped)
  109. print("dropping -",amountDropped)
  110. elseif turtle.getItemCount() == 64 then
  111. local amountDropped = turtle.getItemCount()
  112. turtle.dropDown(64)
  113. print("dropping -",amountDropped)
  114. end
  115. turtle.forward()
  116. end
  117. end
  118.  
  119. function goHome()
  120. turtle.turnLeft()
  121. turtle.turnLeft()
  122. turtle.forward()
  123. atStart = false
  124. while atStart == false do
  125. local isBlock, data= turtle.inspectDown()
  126. if(data.name == "minecraft:furnace" ) then
  127. turtle.forward()
  128. elseif (data.name == "byg:fir_fence") then
  129. turtle.turnLeft()
  130. for i = 1, 5, 1 do
  131. turtle.forward()
  132. end
  133. elseif (data.name == "charm:oak_chest") then
  134. turtle.turnLeft()
  135. turtle.turnLeft()
  136. atStart = true
  137. end
  138. end
  139. end
  140.  
  141. function goToWork()
  142. while turtle.detect() == false do
  143. turtle.forward()
  144. end
  145. turtle.turnRight()
  146. turtle.forward()
  147. end
  148.  
  149. function transfer()
  150. getWood()
  151. goToWork()
  152. depositWood()
  153. getFuel()
  154. goHome()
  155. sleep(600)
  156. end
  157.  
  158. while true do
  159. transfer()
  160. end
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement