zurbo

cc_turtleSens_WIP

Dec 17th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. function detSens()
  2.   local sens = "0"
  3.   x0,y0,z0 = gps.locate()
  4.   step(1)
  5.   x1,y2,z2 = gps.locate()
  6.   turtle.left(2)
  7.   step(1)
  8.   turtle.right(2)
  9.   local Xc = x0 - x1
  10.   local Yc = y0 - y1
  11.  
  12.   If not (Xc == 0) then
  13.     If (Xc < 0) then
  14.       sens = "east"
  15.     else
  16.       sens = "west"
  17.     end
  18.   end
  19.  
  20.   If not (Yc == 0) then
  21.     If (Yc < 0) then
  22.       sens = "south"
  23.     else
  24.       sens = "north"
  25.     end
  26.   end
  27.  
  28.   return (sens)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment