So, if your are looking for time efficiency, I have a bit of input.
If you want to detect gravel falling on top of the turtle, you will have to waste a little bit of time no matter what you do. This is because the turtle.dig function takes something like 0.2 seconds (someone did the research on this, I don't remember where though). So what happens is you go forward, you mine up, releasing a gravel block. While the block is falling, there is nothing else there, so the turtle moves to the next step. You mine down and move on.
If you wanted to be most time efficient, you would mine up, mine down, then check again. However, the gravel still has 0.15 seconds (according to your research) before it finishes falling. You will have to sleep for this time.
Assuming you have done the above, you now have two options, you could try detecting (I think 0.05 seconds), then dig if true, or just try digging (0.2 seconds). If either returned true, you would wait 0.35 seconds again.
No matter which option you pick, every dig move you make will be at least 0.2 seconds slower than a regular dig move if you want to be certain that you got gravel.
The code for this would look like this:
while not turtle.forward() do
while turtle.dig() do end
local flag = turtle.digUp()
turtle.digDown()
if flag then
--#sleep(0.15) --#Wait for gravel. This should be unnecessary, see edit
if turtle.detectUp() then
while turtle.digUp() do
sleep(0.35)
end
end
end
end
Another thing to note (that I recently modified in my quarry) is that if you plan for more than half of your path to be mining, then put another "turtle.dig()" before your "while not turtle.forward()" because a failed turtle.forward call wastes time.
I'll see if I can find that research page again, if you have any other questions or criticisms let me know
Edit: I found the post. It was from AustinKK in
his quarry here . However, that post is from December 2012, so I'm not sure how accurate it is.
Quote
Move (forward/back/up/down): 0.4s
Turn (right/left): 0.4s
Dig (up/down/front): 0.4s
Detect (front/up/down): 0.05s
Compare (front/up/down): 0.05s
He says that apparently a turtle digging costs 0.4 seconds, not 0.2 seconds. Therefore, you wouldn't have to sleep for 0.15 seconds, and your turtle would only be 0.05 seconds slower per movement. As long as your measurements are accurate, you should be good to go with just checking after you dig down.
Edited by civilwargeeky, 22 November 2014 - 04:11 AM.