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

[turtle] gravel proof

Started by Heroj04, 28 September 2012 - 07:12 AM
Heroj04 #1
Posted 28 September 2012 - 09:12 AM
So I was making a tunneling program but I don't know how to gravel proof it, without slowing it down too much.
This is the main idea of the program, it repeats this.
I've tried waiting for a second so the gravel can fall before checking, but this makes it really slow when mining long tunnels.

Turtle.dig()
Turtle.forward()
Turtle.digUp

Any way to do it
Doyle3694 #2
Posted 28 September 2012 - 09:19 AM
local times
print("How many times would you like to run?")
times = tonumber(read())

for i=1, times do
sleep(0.1)
while not turtle.forward() do
turtle.dig()
end
end
Heroj04 #3
Posted 28 September 2012 - 09:25 AM
local times
print("How many times would you like to run?")
times = tonumber(read())

for i=1, times do
while not turtle.forward() do
turtle.dig()
end
end

I've already tried something similar to this but, the turtle detects nothing and moves forward before the gravel falls often :P/>/>

local times
print("How many times would you like to run?")
times = tonumber(read())

for i=1, times do
while not turtle.forward() do
turtle.dig()
end
end

I've already tried something similar to this but, the turtle detects nothing and moves forward before the gravel falls often :D/>/>
Luanub #4
Posted 28 September 2012 - 09:26 AM
Just add a small sleep after the dig to give the gravel time to fall.
Heroj04 #5
Posted 28 September 2012 - 09:36 AM
Just add a small sleep after the dig to give the gravel time to fall.

Yea it seems this is the only way, although it makes the turtle slower, oh well
Luanub #6
Posted 28 September 2012 - 09:46 AM
It doesn't have to be a long sleep I use 0.1 and it works just fine.
Doyle3694 #7
Posted 28 September 2012 - 10:04 AM
I havn't really needed such a program so never programed one, this was what came up form the top of my head

I update the other program to work
Luanub #8
Posted 28 September 2012 - 10:13 AM
It should be in the while loop along with the dig. The way you have it will make it sleep then start the loop, not sleeping again until the next step. It won't wait for the gravel before trying to move again.

Corrected:

local times
print("How many times would you like to run?")
times = tonumber(read())

for i=1, times do
  while not turtle.forward() do
    turtle.dig()
    sleep(0.1)
  end
end
Doyle3694 #9
Posted 28 September 2012 - 10:41 AM
oh, yeah, code optimization….. You know I suck on that right?