Advertisement
TechManDylan

facing

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