View difference between Paste ID: ruiUdCcH and J2pcaLBW
SHOW: | | - or go back to the newest paste.
1-
local t = turtle; local f=t.forward;t.forward=function() while not f() do end end; t.r,t.x,t.y,t.z=0,0,0,0; t.tr=t.turnRight; 
1+
turtle.rot, turtle.x, turtle.y, turtle.z = 0,0,0,0
2-
t.tl=t.turnLeft; t.tt=function(r) local d=t.r>r and t.r-r or r-t.r; if (d==0) then return true end; if (d==2) then t.tr() t.tr() end; 
2+
local forward=turtle.forward; turtle.forward=function() while not forward() do end end
3-
if (d==1) then if (t.r>r) then t.tl() else t.tr() end end; if (d==3) then if (t.r>r) then t.tr() else t.tl() end end; t.r=r; end; 
3+
turtle.turnTo = function(rot) --KISS: Keep It Simple, Stupid
4-
t.goto=function(x,y,z) local tX,tZ=(x>t.x and 1 or 3), (z>t.z and 0 or 2); local dX,dY,dZ=(x>t.x and 1 or -1), (y>t.y and 1 or -1),
4+
    local diff = turtle.rot>rot and turtle.rot-rot or rot-turtle.rot
5-
(z>t.z and 1 or -1); while (t.x~=x) do t.tt(tX) t.forward() t.x=t.x+dX end; while (t.z~=z) do t.tt(tZ) t.forward() 
5+
    if (diff==0) then return true end
6-
t.z=t.z+dZ end; while (t.y~=y) do if (dY==1) then t.up() else t.down() end t.y=t.y+dY end; end; t.turnTo=t.tt;
6+
    if (diff==2) then turtle.turnRight() turtle.turnRight() end
7
    if (diff==1) then if (turtle.rot>rot) then turtle.turnLeft() else turtle.turnRight() end end
8
    if (diff==3) then if (turtle.rot>rot) then turtle.turnRight() else turtle.turnLeft() end end
9
    turtle.rot = rot
10
end
11
turtle.goto = function(x,y,z)
12
    local tX, tZ = (x>turtle.x and 1 or 3), (z>turtle.z and 0 or 2)
13
    local dX, dY, dZ = (x>turtle.x and 1 or -1),(y>turtle.y and 1 or -1),(z>turtle.z and 1 or -1)
14
    while (turtle.x~=x) do turtle.turnTo(tX) turtle.forward() turtle.x=turtle.x+dX end
15
    while (turtle.z~=z) do turtle.turnTo(tZ) turtle.forward() turtle.z=turtle.z+dZ end
16
    while (turtle.y~=y) do if (dY==1) then turtle.up() else turtle.down() end turtle.y=turtle.y+dY end
17
end