Posted 05 August 2012 - 11:52 PM
This is my program:
When I run it however, the variable k (a counter) doesn't increment like it should and causes the turtle to go in the wrong direction. I have no idea why it's not incrementing like it should.
Please Help
Edit: if you can't figure out why, offering a work around would also be acceptable..
Spoiler
function digFloor(k)
i=1
j=1
msg=tostring(k)
rednet.send(5, msg) --debugging effort
if k==1 or k==3 or k==5 then --sets the direction to turn for the first line in a layer
forward=true
else
forward=false
end
for j=1,10,1 do --cuts out a 10x10x1 layer of blocks
for i=1,9,1 do
turtle.dig()
turtle.forward()
end
if j~=10 then --prevents the turning from breaking the pattern on the last instance of loop
if forward == false then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
forward=true
else
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
forward=false
end
else
turtle.turnLeft()
turtle.turnLeft()
end
end
end
i=0
k=1
down=true
x,y= rednet.receive() --receives the command to start the process
print(y) --confirmation of message
if turtle.detect() then --checks to see if layer at turtle's level
down=false
end
if y=="quarry" then
for i=1,5,1 do
if down==false then
digFloor(k)
k=k+1
down=true
else --if not then digs down one and continues for 5 layers
turtle.digDown()
turtle.down()
digFloor(k)
k=k+1
down=true
end
end
shell.run("go", "left", "2") --goes back to start point
shell.run("go", "forward", "9")
shell.run("go", "right")
shell.run("go", "forward", 9)
shell.run("go", "up", "5")
for i=1,9,1 do --drops off the contents into a chest
turtle.select(i)
turtle.drop(64)
end
end
When I run it however, the variable k (a counter) doesn't increment like it should and causes the turtle to go in the wrong direction. I have no idea why it's not incrementing like it should.
Please Help
Edit: if you can't figure out why, offering a work around would also be acceptable..