MudkipTheEpic

GetDirection function... Thanks Lyqyd

Mar 3rd, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.39 KB | None | 0 0
  1. local vec1 = vector.new(gps.locate(2, false))
  2. turtle.forward()
  3. local vec2 = vector.new(gps.locate(2, false))
  4. turtle.back()
  5. local heading
  6. if vec1 and vec2 then
  7.   local resultVec = vec2 - vec1
  8.   heading = ((resultVec.x + math.abs(resultVec.x) * 2) + (resultVec.z + math.abs(resultVec.z) * 3)) % 4
  9.   --heading now contains a number 0-3 corresponding directly to the minecraft direction codes.
  10. end
Advertisement
Add Comment
Please, Sign In to add comment