--TurtleNav v0.1 x = 0 --l&r z z = 0 --f&b | y = 0 --u&d y--x direction = 1 function orient(dir) dif = direction-dir if (dif == -1) or (dif == 3) then turtle.turnRight() elseif (dif == -2) or (dif == 2) then turtle.turnRight() turtle.turnRight() elseif (dif == -3) or (dif == 1) then turtle.turnLeft() end direction = dir if debug == true then print("Difference = "..dif) end end function forward() repeat until turtle.forward() == true if direction == 1 then z = z+1 elseif direction == 2 then x = x+1 elseif direction == 3 then z = z-1 elseif direction == 4 then x = x-1 end end function back() repeat until turtle.back() == true if direction == 1 then z = z-1 elseif direction == 2 then x = x-1 elseif direction == 3 then z = z+1 elseif direction == 4 then x = x+1 end end function up() repeat until turtle.up() == true y = y+1 end function down() repeat until turtle.down() == true y = y-1 end function travel(dX,dZ,dY) if dX > x then orient(2) elseif dX < x then orient(4) end for i = 0,math.abs(dX-x),1 do forward() end if dZ > z then orient(1) elseif dZ < z then orient(3) end for i = 0,math.abs(dZ-z),1 do forward() end if dY > y then for i = 0,math.abs(dY-y),1 do up() end elseif dY < y then for i = 0,math.abs(dY-y),1 do down() end end end