Posted 12 January 2013 - 05:12 PM
Oh how my brain hurts. I'm usually pretty good at coding, but I'm trying to figure out how best to modify and simplify my code. If anyone can help me out with this, I'll be your best friend for longer than forever.
My goal is to have my turtle:
- dig a 2 high, 1 wide tunnel 101 blocks long
- place a torch on the upper block (upper block so it doesn't stop the turtle on its return, and left or right side doesn't matter) on the 2nd block in, and every 11 blocks after that, with the 101st block being where the final torch is placed
- before breaking each block, check to see if it's diamond ore (a piece of diamond ore will be placed in slot 16), if it is, return back to the starting point (allowing me to get my fortune 3 pick and cash in on some diamonds)
- and upon completion of said tunnel, return to its start point, at which time I'll remove its contents, pick it up, and place it back down to begin the next tunnel
Here's my code so far:
As you can see, I haven't yet implemented the torch placing script, and I'm sure what I've got there can be majorly simplified.
Please help me Obi-Wan, you're my only hope…or something to that effect, Lol.
My goal is to have my turtle:
- dig a 2 high, 1 wide tunnel 101 blocks long
- place a torch on the upper block (upper block so it doesn't stop the turtle on its return, and left or right side doesn't matter) on the 2nd block in, and every 11 blocks after that, with the 101st block being where the final torch is placed
- before breaking each block, check to see if it's diamond ore (a piece of diamond ore will be placed in slot 16), if it is, return back to the starting point (allowing me to get my fortune 3 pick and cash in on some diamonds)
- and upon completion of said tunnel, return to its start point, at which time I'll remove its contents, pick it up, and place it back down to begin the next tunnel
Here's my code so far:
d = 0
repeat
turtle.select(16)
if turtle.compare() == false then
turtle.dig()
turtle.forward()
d = d + 1
end
if turtle.compare() == true then
turtle.turnRight()
turtle.turnRight()
repeat
turtle.forward()
d = d - 1
until d == 0
end
if turtle.compareUp() == false then
turtle.digUp()
d = d + 1
end
if turtle.compareUp() == true then
turtle.turnRight()
turtle.turnRight()
repeat
turtle.forward()
d = d - 1
until d == 0
end
until d == 202
turtle.turnRight()
turtle. turnRight()
repeat
if d > 0 then
turtle.forward()
d = d - 1
end
until d == 0
As you can see, I haven't yet implemented the torch placing script, and I'm sure what I've got there can be majorly simplified.
Please help me Obi-Wan, you're my only hope…or something to that effect, Lol.