Jump to content




[turtle] gravel proof


  • You cannot reply to this topic
8 replies to this topic

#1 Heroj04

  • Members
  • 32 posts

Posted 28 September 2012 - 08: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

#2 Doyle3694

  • Members
  • 815 posts

Posted 28 September 2012 - 08: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


#3 Heroj04

  • Members
  • 32 posts

Posted 28 September 2012 - 08:25 AM

View PostDoyle3694, on 28 September 2012 - 08:19 AM, said:

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/>

View PostDoyle3694, on 28 September 2012 - 08:19 AM, said:

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/>

#4 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 28 September 2012 - 08:26 AM

Just add a small sleep after the dig to give the gravel time to fall.

#5 Heroj04

  • Members
  • 32 posts

Posted 28 September 2012 - 08:36 AM

View Postluanub, on 28 September 2012 - 08:26 AM, said:

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

#6 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 28 September 2012 - 08:46 AM

It doesn't have to be a long sleep I use 0.1 and it works just fine.

#7 Doyle3694

  • Members
  • 815 posts

Posted 28 September 2012 - 09: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

#8 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 28 September 2012 - 09: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


#9 Doyle3694

  • Members
  • 815 posts

Posted 28 September 2012 - 09:41 AM

oh, yeah, code optimization..... You know I suck on that right?





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users