This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mlmiii's profile picture

How do you gravel-proof a mining program?

Started by Mlmiii, 13 April 2012 - 11:19 AM
Mlmiii #1
Posted 13 April 2012 - 01:19 PM
Ok, so I have a simple mining program I use in loops, but it gets stuck when encountering gravel. I would like to make it able to go through gravel without prematurely ending.


turtle.dig()
turtle.forward()
turtle.digUp()
Wolvan #2
Posted 13 April 2012 - 01:43 PM
I would try it like this:
Dig
Wait a short time
if turtle.detect() then

turtle.dig()
else
turtle.forward()
end
and run that code again
kamnxt #3
Posted 13 April 2012 - 04:54 PM
Try:

while not turtle.forward() do
turtle.dig()
end
Luanub #4
Posted 13 April 2012 - 09:18 PM
You do something like this too which will wait until the path is clear

if turtle.forward() == false then
		repeat
		turtle.dig()
		sleep(0.25)  -- small sleep to allow for gravel/sand to fall.
		until turtle.forward() == true
end

This will also help if a mob/player steps in front of the turtle as well.
Edited on 13 April 2012 - 07:20 PM
Mlmiii #5
Posted 14 April 2012 - 01:31 AM
Thanks, all.