gundami

Untitled

Oct 24th, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. local relay = peripheral.find("redstone_relay")
  2. local ship = peripheral.find("vs_ship")
  3.  
  4. if not ship or not relay then
  5. print("Error: Missing peripherals!")
  6. return
  7. end
  8.  
  9. print("======================================")
  10. print(" Coordinate System Debug")
  11. print("======================================")
  12.  
  13. while true do
  14. print("\nPress ENTER for test...")
  15. read()
  16.  
  17. local pos = ship.getWorldspacePosition()
  18. local euler = ship.getEulerAnglesYXZ()
  19. local yaw = euler.y
  20.  
  21. -- Target
  22. local targetX = 364
  23. local targetZ = 139
  24.  
  25. local dx = targetX - pos.x
  26. local dz = targetZ - pos.z
  27.  
  28. print(string.format("\nCurrent: (%.1f, %.1f)", pos.x, pos.z))
  29. print(string.format("Target: (%d, %d)", targetX, targetZ))
  30. print(string.format("\ndx = %.1f (target %s of ship)", dx, dx > 0 and "EAST" or "WEST"))
  31. print(string.format("dz = %.1f (target %s of ship)", dz, dz > 0 and "SOUTH" or "NORTH"))
  32. print(string.format("\nCurrent Yaw: %.1f°", math.deg(yaw)))
  33.  
  34. -- Try different atan2 combinations
  35. local h1 = math.atan2(dx, dz)
  36. local h2 = math.atan2(dz, dx)
  37. local h3 = math.atan2(-dx, dz)
  38. local h4 = math.atan2(dx, -dz)
  39.  
  40. print("\nTrying different atan2 formulas:")
  41. print(string.format("1. atan2(dx, dz) = %.1f°", math.deg(h1)))
  42. print(string.format("2. atan2(dz, dx) = %.1f°", math.deg(h2)))
  43. print(string.format("3. atan2(-dx, dz) = %.1f°", math.deg(h3)))
  44. print(string.format("4. atan2(dx, -dz) = %.1f°", math.deg(h4)))
  45.  
  46. print("\nWhich one makes sense?")
  47. print("Manually check your compass/map!")
  48. end
Add Comment
Please, Sign In to add comment