Mod Request : Where am I

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Aniem
Posts: 1
Joined: Tue, 10. Jun 25, 16:01

Mod Request : Where am I

Post by Aniem »

Hi everyone !

This is half a request, and more of a question, because I'm surprised nobody has done this before :
I'd like a mod that insert somewhere (in the info box in the ship, in the information menu, or elsewhere rather easily findable) the player's (or any ship's or point, really, doesn't really matter) position.
Like the sector (easy, we already have), but also the x y z coordinates inside that sector.
I've seen it's rather easy to fetch the player's coordinates, but I don't know (yet?) how to create a mod or how to change a small part of the UI to include this without requiring a shitton of libraries.
I'd even be happy if I knew how to send these coordinates somewhere on the network to have it display it in a terminal or whatever.

Its just a pain trying to find some object (datavaults, khaaks, abandoned ships for instance), having tools to get their coordinates, and then just stumbling around an estimation of where it should be, estimating a sector center, angles and distances from that.
staeuber
Posts: 33
Joined: Tue, 8. Feb 05, 00:36
x4

Re: Mod Request : Where am I

Post by staeuber »

I've actually wanted something like this too - it's super frustrating trying to find specific objects when you only have rough coordinates.
Here are a few ways you could implement this, from simple to fancy: (not tested myself but should work)
Easiest Solution: Notification Display
The quickest way is to use X4's notification system. Just create a simple MD script that shows your coordinates when you press a hotkey:

Code: Select all

<!-- File: md/coordinate_display.xml -->
<?xml version="1.0" encoding="utf-8"?>
<mdscript name="CoordinateDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<cues>
<cue name="ShowCoordinates">
<conditions>
<event_player_input_received input="'INPUT_STATE_DETAILMONITOR_BACK'"/>
</conditions>
<actions>
<set_value name="$pos" exact="player.entity.position"/>
<show_notification
text="'Position: X=' + [($pos.x/1000), 1] + 'km, Y=' + [($pos.y/1000), 1] + 'km, Z=' + [($pos.z/1000), 1] + 'km'"
timeout="10s"/>
</actions>
</cue>
</cues>
</mdscript>
Just drop this in your extensions/YourMod/md/ folder and whenever you press the detail monitor back key, you'll get a notification with your exact coordinates in kilometers. Super handy for noting down datavault locations!
Fancier Option: HUD Display
If you want coordinates always visible, you could patch the HUD to show them permanently in a corner. This requires UI modding but gives you constant position awareness.
Best for Your Use Case: Info Panel Integration
You could also add coordinates to the ship info panel so they show up whenever you open ship details. This feels more "native" to the game.
Network Solution
For the network idea - you could have the mod write coordinates to the debug log in a specific format, then use a simple Python script to read that log and display coordinates in a web browser or terminal. Pretty cool for dual-monitor setups!
Honestly, I'd start with the notification approach since it's dead simple to implement and does exactly what you need. No complex UI work, no library dependencies, just a basic MD script that gives you coordinates on demand.
The coordinates come out in meters by default, so I divided by 1000 to get kilometers which are way easier to work with. You could even modify it to show distance and bearing to a saved waypoint if you wanted to get fancy.
Want me to explain any of these approaches in more detail? The notification method should take you like 5 minutes to set up.
keine
User avatar
beko
Posts: 81
Joined: Thu, 11. Jun 20, 21:14
x4

Re: Mod Request : Where am I

Post by beko »

I drop the current position in the ship telemetry of the X4-Simpit mod. My local version also knows the system already but I didn't push that yet to GitHub.

The solution is similar to the suggested variant 3 and has the data available via a socket from where I read it for my simulated home cockpit. That will need some work on your side though because I'm only scratching my own itch here and this is designed to be consumed by external solutions outside of the game that you probably do not have.

Image
("Pos" holds x,y,z in the current sector, older screenshot I had around)

Project is here if you want to see how it's done: https://github.com/bekopharm/x4-simpit - some changes needed for v7.x are not yet pushed through. I may elaborate further if this is of interest for you.

Return to “X4: Foundations - Scripts and Modding”