Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - function goto( gx, gy, gz )
 - if gx == nil or gy == nil or gz == nil then
 - return
 - end
 - --defining x, y, z, f position
 - cx, cy, cz = gps.locate( 2, false )
 - if cf == nil then
 - turtle.dig()
 - repeat until turtle.forward()
 - local fx, fy, fz = gps.locate( 2, false )
 - if cz < fz then
 - cf = 0
 - elseif cx > fx then
 - cf = 1
 - elseif cz > fz then
 - cf = 2
 - elseif cx < fx then
 - cf = 3
 - end
 - repeat until turtle.back()
 - end
 - while cx ~= gx or cz ~= gz do
 - if cf == 0 then
 - if cx < gx then
 - turtle.turnLeft()
 - cf = 3
 - elseif cx > gx or cz > gz then
 - turtle.turnRight()
 - cf = 1
 - end
 - elseif cf == 1 and cx <= gx then
 - if cz > gz or cx ~= gx then
 - turtle.turnRight()
 - cf = 2
 - elseif cz < gz then
 - turtle.turnLeft()
 - cf = 0
 - end
 - elseif cf == 2 then
 - if cx > gx then
 - turtle.turnLeft()
 - cf = 1
 - elseif cx < gx or cz < gz then
 - turtle.turnRight()
 - cf = 3
 - end
 - elseif cf == 3 and cx >= gx then
 - if cz < gz or cx ~= gx then
 - turtle.turnRight()
 - cf = 0
 - elseif cz > gz then
 - turtle.turnLeft()
 - cf = 2
 - end
 - end
 - if cf == 1 or cf == 3 then
 - while cx ~= gx or not turtle.detectDown() do
 - if turtle.down() then
 - cy = cy - 1
 - elseif cx ~= gx then
 - while not turtle.forward() do
 - while not turtle.up() do
 - while not turtle.back() do
 - while not turtle.down() do
 - return
 - end
 - cy = cy - 1
 - end
 - if cf == 1 then
 - cx = cx + 1
 - else
 - cx = cx - 1
 - end
 - end
 - cy = cy+1
 - end
 - if cf == 1 then
 - cx = cx - 1
 - else
 - cx = cx + 1
 - end
 - end
 - end
 - elseif cx == gx then
 - while cz ~= gz or not turtle.detectDown() do
 - if turtle.down() then
 - cy = cy - 1
 - elseif cz ~= gz then
 - while not turtle.forward() do
 - while not turtle.up() do
 - while not turtle.back() do
 - while not turtle.down() do
 - return
 - end
 - cy = cy - 1
 - end
 - if cf == 0 then
 - cz = cz - 1
 - else
 - cz = cz + 1
 - end
 - end
 - cy = cy + 1
 - end
 - if cf == 0 then
 - cz = cz + 1
 - else
 - cz = cz - 1
 - end
 - end
 - end
 - end
 - end
 - while cy ~= gy do
 - if cy < gy then
 - turtle.digUp()
 - if turtle.up() then
 - cy = cy + 1
 - end
 - else
 - turtle.digDown()
 - if turtle.down() then
 - cy = cy - 1
 - end
 - end
 - end
 - end
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment