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

Need help with logic problems, code is for a quarry

Started by TRU3XV3T3R4N, 29 August 2013 - 05:32 PM
TRU3XV3T3R4N #1
Posted 29 August 2013 - 07: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
Goof #2
Posted 30 August 2013 - 01:09 AM
Did you fuel the turtle?
CCJJSax #3
Posted 30 August 2013 - 03: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 ;)/>
CCJJSax #4
Posted 30 August 2013 - 03: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.
floppyjack #5
Posted 30 August 2013 - 07:54 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.

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.
TRU3XV3T3R4N #6
Posted 30 August 2013 - 07:11 PM
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
CCJJSax #7
Posted 30 August 2013 - 09:05 PM
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 :)/>