Advertisement
DevilTvLP

ComputerCraft Item puller

Apr 16th, 2025 (edited)
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- Pulls all items of the target item
  2. -- except for 1 Stack out of the
  3. -- inventory in front of the turtle
  4. -- and places it in the inventory
  5. -- behind the turtle
  6.  
  7. local TARGET_ITEM = "minecraft:blaze_rod"
  8.  
  9. local supplyChest = peripheral.wrap("front")
  10. local targetChest = peripheral.wrap("back")
  11.  
  12. function transferItems()
  13.     local firstFoundSlot = 0
  14.     for slot, item in pairs(supplyChest.list()) do
  15.         if item.name == TARGET_ITEM then
  16.             if firstFoundSlot == 0 then
  17.                 firstFoundSlot = slot
  18.             else
  19.                 supplyChest.pushItems(peripheral.getName(targetChest), slot)
  20.             end
  21.         end
  22.     end
  23. end
  24.  
  25. if supplyChest == nil then
  26.     print("No supply chain found in front of the turtle")
  27. elseif targetChest == nil then
  28.     print("No target chest found behind the turtle")
  29. else
  30.     term.clear()
  31.     term.setCursorPos(1, 1)
  32.     term.write("Transfering items...")
  33.     -- loop transfer
  34.     while true do
  35.         transferItems()
  36.         sleep(1)
  37.     end
  38. end
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement