Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local relay = peripheral.find("redstone_relay")
- local ship = peripheral.find("vs_ship")
- if not ship or not relay then
- print("Error: Missing peripherals!")
- return
- end
- print("======================================")
- print(" Coordinate System Debug")
- print("======================================")
- while true do
- print("\nPress ENTER for test...")
- read()
- local pos = ship.getWorldspacePosition()
- local euler = ship.getEulerAnglesYXZ()
- local yaw = euler.y
- -- Target
- local targetX = 364
- local targetZ = 139
- local dx = targetX - pos.x
- local dz = targetZ - pos.z
- print(string.format("\nCurrent: (%.1f, %.1f)", pos.x, pos.z))
- print(string.format("Target: (%d, %d)", targetX, targetZ))
- print(string.format("\ndx = %.1f (target %s of ship)", dx, dx > 0 and "EAST" or "WEST"))
- print(string.format("dz = %.1f (target %s of ship)", dz, dz > 0 and "SOUTH" or "NORTH"))
- print(string.format("\nCurrent Yaw: %.1f°", math.deg(yaw)))
- -- Try different atan2 combinations
- local h1 = math.atan2(dx, dz)
- local h2 = math.atan2(dz, dx)
- local h3 = math.atan2(-dx, dz)
- local h4 = math.atan2(dx, -dz)
- print("\nTrying different atan2 formulas:")
- print(string.format("1. atan2(dx, dz) = %.1f°", math.deg(h1)))
- print(string.format("2. atan2(dz, dx) = %.1f°", math.deg(h2)))
- print(string.format("3. atan2(-dx, dz) = %.1f°", math.deg(h3)))
- print(string.format("4. atan2(dx, -dz) = %.1f°", math.deg(h4)))
- print("\nWhich one makes sense?")
- print("Manually check your compass/map!")
- end
Add Comment
Please, Sign In to add comment