Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hibernationCount = 0 --variable to count the number of inactive cycles
- function compare()
- if turtle.getItemCount(1) > 0 then --checks to see if there is an item in the active slot
- hibernationCount = 0 --resets hibernation count
- print("item in sorting slot...")
- for i=2,16 do --cycles through all sorting slots
- if turtle.compareTo(i) then --checks to see if item in active slot compares to sorting slots
- print("item is an ore")
- while not turtle.dropDown(turtle.getItemCount(1)) do --drops item down if it compares to sorting slot, if it returns false, it waits and emits a redstone signal
- redstone.setOutput("top", true)
- sleep(1)
- print("chest Full...")
- redstone.setOutput("top", false)
- sleep(1)
- end
- return
- end
- end
- while not turtle.drop(turtle.getItemCount(1)) do -- attemps to drop item forward, if it fails, it waits and emits a redstone signal
- print("jam ahead...")
- sleep(5)
- end
- print("item is NOT an ore")
- else
- print("waiting for item...")
- sleep(0.5)
- hibernationCount = hibernationCount + 1
- if hibernationCount > 10 then --if compare function runs more than 10x, the turtle hibernates for 5 seconds
- print("hibernating...")
- sleep(5)
- for i=2,16 do
- if turtle.getItemCount(i) > 1 then --turns any stacks of items in the sorting slots into single items, is a housekeeping function
- turtle.select(i)
- turtle.dropDown(turtle.getItemCount(i)-1)
- turtle.select(1)
- end
- end
- end
- end
- end
- while true do
- compare()
- end
Advertisement
Add Comment
Please, Sign In to add comment