BigGamingGamers

Untitled

Dec 14th, 2020 (edited)
5,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. local SLOT_COUNT = 16
  2. local FUEL_CHEST = 15
  3. local TNT_CHEST = 16
  4.  
  5. local FILL_SLOT_COUNT = 4
  6.  
  7.  
  8. local modem = peripheral.wrap("left")
  9. modem.open(100)
  10.  
  11. function countItems(itemToCount)
  12. local itemCount = 0
  13. for slot = 1, SLOT_COUNT, 1 do
  14. item = turtle.getItemDetail(slot)
  15. if(item ~= nil) then
  16. if(item.name == itemToCount) then
  17. itemCount = itemCount + turtle.getItemCount(slot)
  18. end
  19. end
  20. end
  21.  
  22. return itemCount
  23. end
  24.  
  25.  
  26. function checkFuel()
  27. if(turtle.getFuelLevel() < 100) then
  28. turtle.select(FUEL_CHEST)
  29. turtle.digUp()
  30. turtle.placeUp()
  31. --Chest is deployed
  32.  
  33. turtle.suckUp()
  34.  
  35. while(true) do
  36. bucketIndex = getItemIndex("minecraft:lava_bucket")
  37. if(bucketIndex == nil) then
  38. turtle.suckUp()
  39. turtle.dropUp()
  40. else
  41. turtle.select(bucketIndex)
  42. turtle.refuel()
  43. turtle.dropUp()
  44. turtle.digUp()
  45. return true
  46. end
  47. end
  48. end
  49. return true
  50. end
  51.  
  52.  
  53.  
  54. function checkTNT()
  55. if (countItems("minecraft:tnt") < 64) then
  56. turtle.select(TNT_CHEST)
  57. turtle.digUp()
  58. turtle.placeUp()
  59.  
  60. for slot = 1, FILL_SLOT_COUNT, 1 do
  61. turtle.select(slot)
  62. turtle.suckUp()
  63. end
  64.  
  65. turtle.select(TNT_CHEST)
  66. turtle.digUp()
  67. end
  68. end
  69.  
  70. function getItemIndex(itemName)
  71. for slot = 1, SLOT_COUNT, 1 do
  72. local item = turtle.getItemDetail(slot)
  73. if(item ~= nil) then
  74. if(item["name"] == itemName) then
  75. return slot
  76. end
  77. end
  78. end
  79. end
  80.  
  81.  
  82. print("Waiting for signal")
  83. event, side, senderChannel, replyChannel, msg, distance = os.pullEvent("modem_message")
  84. redstone.setOutput("bottom", true)
  85.  
  86. while(true) do
  87. checkFuel()
  88. checkTNT()
  89.  
  90.  
  91. turtle.forward()
  92.  
  93.  
  94.  
  95. turtle.select(getItemIndex("minecraft:tnt"))
  96. turtle.placeDown()
  97. turtle.placeDown()
  98. turtle.placeDown()
  99. turtle.placeDown()
  100. turtle.placeDown()
  101. end
Add Comment
Please, Sign In to add comment