Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getFaceTo()
- local pos0 = vector.new(gps.locate())
- turtle.forward()
- local pos1 = vector.new(gps.locate())
- local dist = pos1 - pos0
- turtle.back()
- local faceto = ""
- if dist.x > 0 then
- faceto = "west"
- elseif dist.x < 0 then
- faceto = "east"
- elseif dist.z > 0 then
- faceto = "north"
- else
- faceto = "south"
- end
- return faceto
- end
- local function forback(dist)
- d = dist
- if d < 0 then
- d = -d
- end
- if dist > 0 then
- print("forward:"..tostring(d))
- else
- print("back:"..tostring(d))
- end
- end
- local function dispStatus(pos, target, faceto)
- print("pos:"..tostring(pos))
- print("faceTo:"..faceto)
- print("dist:"..tostring(target - pos))
- end
- args = {...}
- x = tonumber(args[1])
- y = tonumber(args[2])
- z = tonumber(args[3])
- target = vector.new(x, y, z)
- rednet.open("left")
- curpos = vector.new(gps.locate())
- faceto = getFaceTo()
- dispStatus(curpos, target, faceto)
- dist = target - curpos
- forback(dist.z)
Advertisement
Add Comment
Please, Sign In to add comment