Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AtPos(gx,gy,gz)
- print("checking pos")
- cx,cy,cz = gps.locate(1,false)
- if cx == gx and cy == gy and cz == gz then
- return true
- else
- return false
- end
- end
- tArgs = { ...}
- gx=tonumber(tArgs[1])
- gy=tonumber(tArgs[2])
- gz=tonumber(tArgs[3])
- cx,cy,cz = gps.locate(1,false)
- print("I am at "..cx..":x "..cy..":y "..cz..":z")
- print("goint to "..gx..":x "..gy..":y "..gz..":z")
- -- print(cz)
- -- print(cz+1)
- print("debug1")
- while AtPos(gx,gy,gz) == false do
- print("debug2")
- if cz > gz then -- too far north
- shell.run('Turn',2)
- print("facing south")
- print("moving "..math.abs(cz-gz).."meters")
- shell.run('GoForward',(math.abs(cz-gz))) --go south
- elseif cz < gz then -- too far south
- shell.run('Turn',0)
- print("facing north")
- print("moving "..math.abs(cz-gz).."meters")
- shell.run('GoForward',(math.abs(cz-gz))) -- go north
- end
- if cx > gx then -- to far west
- shell.run('Turn',(1))
- print("facing west")
- print("moving "..math.abs(cx-gx).."meters")
- shell.run('GoForward',(math.abs(cx-gx))) -- go e or w
- elseif cx < gx then -- too far east
- shell.run('Turn',(3))
- print("facing east")
- print("moving "..math.abs(cx-gx).."meters")
- shell.run('GoForward',(math.abs(cx-gx))) -- go e or w
- end
- if cy > gy then
- print("moving down")
- turtle.down()
- cx,cy,cz = gps.locate(1,false)
- elseif cy < gy then
- print("moving up")
- turtle.up()
- cx,cy,cz = gps.locate(1,false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement