Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg = { ... }
- local xcord=tonumber(arg[1])
- local ycord=tonumber(arg[2])
- local zcord=tonumber(arg[3])
- if arg[1]==nil
- or
- arg[2]==nil
- or
- arg[3]==nil then
- print("gps <x> <y> <z>")
- return
- end
- function locate()
- g = vector.new(gps.locate(2))
- turtle.forward()
- g2 = vector.new(gps.locate(2))
- turtle.back()
- if g.x == g2.x then
- if g.y > g2.y then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- else
- if g.x > g2.x then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- end
- function calc()
- xmove = xcord - g.x
- if xmove < 0 then xmove=xmove*(-1) end
- ymove = ycord - g.y
- if ymove < 0 then ymove=ymove*(-1) end
- zmove = zcord - g.z
- if zmove < 0 then zmove=zmove*(-1) end
- end
- function move()
- if xcord ~= g.x then
- if xcord < g.x then
- turtle.turnRight()
- for i=1,xmove do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnLeft()
- for i=1,xmove do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- if ycord ~= g.y then
- if ycord > g.y then
- for i=1,ymove do
- turtle.forward()
- end
- else
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,ymove do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- if zcord ~= g.z then
- if zcord < g.z then
- for i=1,zmove do
- turtle.down()
- end
- else
- for i=1,zmove do
- turtle.up()
- end
- end
- end
- end
- locate()
- calc()
- move()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement