Posted 06 October 2012 - 01:08 AM
What I'm trying to accomplish is to get a turtle to clear a path in front of it, turn to the side then come back. I have two functions (clearlong and wturn.) I want to input the values say 10 long and 3 wide. Basically I don't want it to turn after the last 'clearing.' So if I gave it the 3x3 I want it to clearlong 3 times and only turn 2 times. I think I have this right however it is still happening every time.
Here is my function…
When I test it with just numbers it seems to be working fine, however, when using my functions it just won't work. I'm just learning and trying out this coding I'm sorry if this is a simple question so any help would be very helpful, thanks.
wturn
clearlong
Here is my function…
function clearing()
for j=1, wide do
clearlong()
if j~= then
wturn()
end
end
end
When I test it with just numbers it seems to be working fine, however, when using my functions it just won't work. I'm just learning and trying out this coding I'm sorry if this is a simple question so any help would be very helpful, thanks.
wturn
function wturn()
if direction==1 then
turtle.turnRight()
if turtle.detect() then
turtle.dig()
digcount=digcount+1
term.clearLine()
term.setCursorPos(1,1)
write("Current Dig Count Is: "..digcount)
end
turtle.forward()
turtle.turnRight()
direction=direction+1
elseif direction==2 then
turtle.turnLeft()
if turtle.detect() then
turtle.dig()
digcount=digcount+1
term.clearLine()
term.setCursorPos(1,1)
write("Current Dig Count Is: "..digcount)
end
turtle.forward()
turtle.turnLeft()
direction=direction-1
end
end
clearlong
function clearlong()
for i=1,long do
if turtle.detect() then
turtle.dig()
digcount=digcount+1
term.clearLine()
term.setCursorPos(1,1)
write("Current Dig Count Is: "..digcount)
end
turtle.forward()
end
end