Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- turtle.rot, turtle.x, turtle.y, turtle.z = 0,0,0,0
- local forward=turtle.forward; turtle.forward=function() while not forward() do end end
- turtle.turnTo = function(rot) --KISS: Keep It Simple, Stupid
- local diff = turtle.rot>rot and turtle.rot-rot or rot-turtle.rot
- if (diff==0) then return true end
- if (diff==2) then turtle.turnRight() turtle.turnRight() end
- if (diff==1) then if (turtle.rot>rot) then turtle.turnLeft() else turtle.turnRight() end end
- if (diff==3) then if (turtle.rot>rot) then turtle.turnRight() else turtle.turnLeft() end end
- turtle.rot = rot
- end
- turtle.goto = function(x,y,z)
- local tX, tZ = (x>turtle.x and 1 or 3), (z>turtle.z and 0 or 2)
- 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)
- while (turtle.x~=x) do turtle.turnTo(tX) turtle.forward() turtle.x=turtle.x+dX end
- while (turtle.z~=z) do turtle.turnTo(tZ) turtle.forward() turtle.z=turtle.z+dZ end
- while (turtle.y~=y) do if (dY==1) then turtle.up() else turtle.down() end turtle.y=turtle.y+dY end
- end
Advertisement
Add Comment
Please, Sign In to add comment