31 posts
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
818 posts
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
31 posts
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/>/>
1111 posts
Location
Portland OR
Posted 28 September 2012 - 09:26 AM
Just add a small sleep after the dig to give the gravel time to fall.
31 posts
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
1111 posts
Location
Portland OR
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.
818 posts
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
1111 posts
Location
Portland OR
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
818 posts
Posted 28 September 2012 - 10:41 AM
oh, yeah, code optimization….. You know I suck on that right?