civilwargeeky

Claude's Block Placer

Sep 15th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. -- Function to check if the current slot has items
  2. local function hasItems()
  3.     return turtle.getItemCount() > 0
  4. end
  5.  
  6. -- Function to find the next non-empty slot
  7. local function findNextSlot()
  8.     for i = 1, 16 do
  9.         if turtle.getItemCount(i) > 0 then
  10.             turtle.select(i)
  11.             return true
  12.         end
  13.     end
  14.     return false
  15. end
  16.  
  17. -- Main loop
  18. while true do
  19.     if hasItems() then
  20.         -- Place block
  21.         turtle.place()
  22.     else
  23.         -- If current slot is empty, try to find a new non-empty slot
  24.         if not findNextSlot() then
  25.             -- Wait for inventory change if all slots are empty
  26.             print("Waiting for items...")
  27.             os.pullEvent("turtle_inventory")
  28.         end
  29.     end
  30. end
Add Comment
Please, Sign In to add comment