Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- facing = 2
- function turnTo(direction)
- dif = facing-direction
- for i=1,math.abs(dif) do
- if dif<0 then turtle.turnRight()
- elseif dif>0 then turtle.turnLeft()
- end
- end
- facing = direction
- print("Facing "..facing)
- end
- function goSide(side, count)
- turnTo(side)
- for i=1,math.abs(count) do
- if count>0 then turtle.forward()
- elseif count<0 then turtle.backward()
- end
- end
- end
- function goUp(count)
- for i=1,math.abs(count) do
- if count>0 then turtle.up()
- elseif count<0 then turtle.down()
- end
- end
- end
- function goto(x,y,z, tX,tY,tZ)
- dx = tX-x
- dy = tY-y
- dz = tZ-z
- goUp(dy)
- if dx>1 then
- goSide(3,dx)
- elseif dx<-1 then
- goSide(1,-dx)
- end
- if dz>1 then
- goSide(0, dz)
- elseif dz<-1 then
- goSide(2, -dz)
- end
- end
- args = {...}
- x,y,z = gps.locate()
- goto(x,y,z, args[1], args[2], args[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement