Advertisement
TechManDylan

facing direction

Feb 2nd, 2023 (edited)
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. -- Get the initial location
  2. startX, startY, startZ = gps.locate()
  3.  
  4. function currentLocation()
  5.  
  6.   currentX, currentY, currentZ = gps.locate()
  7.  
  8. end
  9.  
  10. function facingDirection()
  11.  
  12.   turtle.forward()
  13.  
  14.   currentLocation()
  15.  
  16.  
  17.   if currentX > startX then
  18.     currentDirection = "east"
  19.   end
  20.  
  21.   if currentX < startX then
  22.     currentDirection = "west"
  23.   end
  24.  
  25.   if currentZ > startZ then
  26.     currentDirection = "south"
  27.   end
  28.  
  29.   if currentZ < startZ then
  30.     currentDirection = "north"
  31.   end
  32.  
  33.   turtle.back()
  34.   print("Facing: "..currentDirection)
  35. end
  36. facingDirection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement