Hey everyone,
I've been working on something for X4 modders who've hit the limits of what Lua and MD XML can do on their own: X4Native — an open-source framework that lets you write X4 mods in C++, with direct access to the game's internals.
Lua is great for UI and glue code, and Mission Director handles game logic well — but some things just aren't possible (or practical) without native code. Think: intercepting game function calls, accessing the full range of 2,000+ exported game functions with proper typing, building performance-critical logic, or bridging game systems in ways Lua alone can't reach. X4Native fills that gap.
This is a first public release. The core framework is functional and tested, but the API may still evolve. Feedback and bug reports are very welcome.
Features
- Full access to X4's exported API (GetPlayerID, GetComponentName, IsPlayerValid, etc.)
- Function hooking — before/after hooks on any game function (inspect args, modify behavior, skip calls)
- Event system — lifecycle events, custom C++ events, and Lua-to-C++ bridges without writing any Lua
- Hot-reloadable core — /reloadui picks up new DLL builds without restarting the game
- Clean C++ SDK — modern C++23, single #include <x4native.h>, everything in the x4n:: namespace
- Auto-discovery — drop extension folders into extensions/, the framework finds and loads them
Code: Select all
#include <x4native.h>
X4N_EXTENSION {
x4n::log::info("Hello X4!");
x4n::on("on_game_loaded", [] {
auto* game = x4n::game();
UniverseID player = game->GetPlayerID();
x4n::log::info("Player ID: {}", player);
});
}- Download x4native-vXXX.zip from the Releases page
- Extract into your X4 extensions/ folder so you have extensions/x4native/
- Disable Protected UI mode in game settings (Settings → Extensions → uncheck Protected Mode)
- Launch the game — check extensions/x4native/x4native.log to verify it loaded
- Grab the SDK zip from the same Releases page
- Point your CMake project at the sdk/ headers
- Build a DLL, drop it in an extension folder with a content.xml and x4native.json, done
Extension Developer Guide
Links
- Download: x4native-vXXX.zip
- Source & Docs: github
- Extension Guide: EXTENSION_GUIDE.md
- Contributions: CONTRIBUTING.md
This is a beta — if you run into issues or have suggestions, open an issue on GitHub or reply here. I'm looking forward to your input.
Happy modding!


