Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if the current slot has items
- local function hasItems()
- return turtle.getItemCount() > 0
- end
- -- Function to find the next non-empty slot
- local function findNextSlot()
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return true
- end
- end
- return false
- end
- -- Main loop
- while true do
- if hasItems() then
- -- Place block
- turtle.place()
- else
- -- If current slot is empty, try to find a new non-empty slot
- if not findNextSlot() then
- -- Wait for inventory change if all slots are empty
- print("Waiting for items...")
- os.pullEvent("turtle_inventory")
- end
- end
- end
Add Comment
Please, Sign In to add comment