AliquotMesozoic

KISS Navigation API (Compressed)

Jul 7th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  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;
  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;
  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;
  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),
  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()
  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;
Advertisement
Add Comment
Please, Sign In to add comment