# Need help with logic problems, code is for a quarry

6 replies to this topic

### #1TRU3XV3T3R4N

• Members
• 4 posts

Posted 29 August 2013 - 06:32 PM

Title: Need help with logic problems, code is for a quarry

here's my code: http://pastebin.com/LvHcagn8
b
asically what i'm trying to do is make a simple quarry which moves forward 8, turns etc and goes down layers. it used to work but now it just rotates continuously :L

### #2Goof

• Members
• 751 posts

Posted 30 August 2013 - 12:09 AM

Did you fuel the turtle?

### #3CCJJSax

• Members
• 262 posts

Posted 30 August 2013 - 02:43 AM

Yeah, if basically the first thing you have it do is do an action that requires fuel, and it skips it, then it's a fuel problem.

also:

```if x < 8 then
while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end
end

```

is a bit redundant. you have two of the same exact checks, "x < 8". In theory this should work exactly the same, just ever so slightly faster.

```while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end

```

PS. I hate this editer that this forum has and how it posts all the color codes and indent codes and all that. makes things impossible
PS. PS. It took many tries to get this readable without the color codes. I hope you appreciate it

### #4CCJJSax

• Members
• 262 posts

Posted 30 August 2013 - 02:56 AM

Also. one more thing. What if this runs into gravel? When putting turtle.dig() into an automatic mining program, more likely than not you'll want to do this.

```while turtle.detect() do -- check for a block
turtle.dig()
sleep(.4)  -- sleeps while potential gravel falls.
end

```

I have heard that the sleep(.4) is unnecessary but I have found that it doesn't work properly without it. especially on a server.

### #5floppyjack

• Members
• 18 posts

Posted 30 August 2013 - 06:54 AM

CCJJSax, on 30 August 2013 - 02:56 AM, said:

Also. one more thing. What if this runs into gravel? When putting turtle.dig() into an automatic mining program, more likely than not you'll want to do this.

In this case, it doesn't make any difference whether it is gravel-safe or not, because the turtle will have dug out every block above the one it is digging out, so there is no gravel above.

But I agree this is useful for tunneling or similar programs.

### #6TRU3XV3T3R4N

• Members
• 4 posts

Posted 30 August 2013 - 06:11 PM

CCJJSax, on 30 August 2013 - 02:43 AM, said:

Yeah, if basically the first thing you have it do is do an action that requires fuel, and it skips it, then it's a fuel problem.

also:

```if x < 8 then
while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end
end

```

is a bit redundant. you have two of the same exact checks, "x < 8". In theory this should work exactly the same, just ever so slightly faster.

```while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end

```

PS. I hate this editer that this forum has and how it posts all the color codes and indent codes and all that. makes things impossible
PS. PS. It took many tries to get this readable without the color codes. I hope you appreciate it
Thanks for the help, turns out it actually DID run out of fuel while testing (extreme derp) sorry for wasting your time and efforts xD and thanks for the help with the actual code CCJJ, i got a little paranoid when writing it, i appreciate the help

### #7CCJJSax

• Members
• 262 posts

Posted 30 August 2013 - 08:05 PM

TRU3XV3T3R4N, on 30 August 2013 - 06:11 PM, said:

CCJJSax, on 30 August 2013 - 02:43 AM, said:

Yeah, if basically the first thing you have it do is do an action that requires fuel, and it skips it, then it's a fuel problem.

also:

```if x < 8 then
while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end
end

```

is a bit redundant. you have two of the same exact checks, "x < 8". In theory this should work exactly the same, just ever so slightly faster.

```while x < 8 do
turtle.dig()
turtle.forward()
x = x + 1
end

```

PS. I hate this editer that this forum has and how it posts all the color codes and indent codes and all that. makes things impossible
PS. PS. It took many tries to get this readable without the color codes. I hope you appreciate it
Thanks for the help, turns out it actually DID run out of fuel while testing (extreme derp) sorry for wasting your time and efforts xD and thanks for the help with the actual code CCJJ, i got a little paranoid when writing it, i appreciate the help

No problem. That's what I'm here for. We all have those derp moments

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users