Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function goto(xx,zz)
- x = tonumber(xx)
- z = tonumber(zz)
- rednet.open("left")
- cx, cy, cz = gps.locate()
- function getDirec()
- if z == cz then
- if x > cx then
- dir = 1
- else
- dir = 3
- end
- elseif cz > z then
- dir = 0
- else
- dir = 2
- end
- end
- function cal()
- for i = 1, dir do
- turtle.turnRight()
- end
- end
- function uncal()
- for o = 1, dir do
- turtle.turnLeft()
- end
- end
- function goZ()
- getDirec()
- cal()
- distzz = cz - z
- distz = math.abs(distzz)
- for p = 1, distz do
- turtle.forward()
- end
- uncal()
- end
- function goX()
- getDirec()
- cal()
- distxx = cx - x
- distx = math.abs(distxx)
- for q = 1, distx do
- turtle.dig()
- turtle.forward()
- end
- uncal()
- end
- goZ()
- goX()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement