----- Date:

x4note - Hacking X4 on Linux

All the work I did last year with X4 Foundations was done on a windows 7 machine, technically less than the minimum requirements for the game but it ran well enough, sort of, and some mods would work. X4 runs native on Linux, and better than it did on Windows 7. Most mods should work.

Now I have my new linux system, and X4 version 3 is out, it's time to go back over the mods I made last year and either update them for v3, or declare them obsolete. For example, Stop Rolling Stones probably works partially, and could be updated; but as I don't have need for it now I'm just declaring it unmaintained.

Unpacking game files #

Steam has the X Tools, which on run on linux using the "Steam Play" / Proton WINE distribution. The Catalog Tool runs OK and can be used to unpack the game's files pretty much as on Windows. There's also SirNukes' X4 Customizer which contains code to pack and unpack the X4/XR catalog files.

My Steam installed its game files in /home/dragon/.steam/debian-installation/steamapps/common/X4 Foundations/; that's an ugly path to use so I've made a symlink:

dragon@skank:~$ ln -s "/home/dragon/.steam/debian-installation/steamapps/common/X4 Foundations/" ./x4install

Something like this is necessary before using the Catalog Tool GUI to unpack game files; the file browser it draws from Proton/WINE didn't show the .steam/ directory when I tried it. The symlink got it there.

Using the X4 Customizer from the command line isn't as immediately straightforward: I had to glance at the (extensive and comprehensive) documentation, and even dig into (freely shared) source code... "The horrors!" ... Also I had to install python3-lxml.

I've put the Customizer code into /work/x4f/X4_Customizer/ so my command line to unpack all the game files is:

 python3 /work/x4f/X4_Customizer/Framework/Main.py -nogui Cat_Unpack
 -argpass ~/x4install ~/xunpack -include "*"

Path names and case #

Linux, unlike Windows, treats case as significant in filenames sometimes. That is, afile.txt may not be the same as AFile.txt; on Windows systems those two names would refer to the same file, on a Linux system they may not.

X4 deals sensibly with this by smashing everything to lowercase before using it as a filename. So my mod that contained a file named md/ResidentArtist.xml worked fine on Windows, but the file wans't found when running under linux. Renaming it to md/residentartist.xml works.

(Of course, packed into a .cat Catalog file, the mod still worked; but the example is too good to pass up for illustrative purposes).

Publishing to Steam #

The WorkshopTool does NOT work full under Proton/WINE, either the 5.x version or 4.11 in my testing. The command runs, but dies without an error message after "Updating workshop item..."

WorkshopTool Failure

I had to spin up a Windows 7 VM on my linux box, install Steam and X tools on that, get it access to the host files by setting up a bridge network and Samba install on skank. Then I can run the WorkshopTool on Windows with access to my live X4 install on linux and the mod folders there, to publish a mod to steam.

WorkshopTool Success

Situations like that are why we call the place "SNAFU Hall".

Saves and Logos #

I found the X4 'user' directory in /home/dragon/.config/EgoSoft/X4/84367608/; this is where the saved games are (in saves/ appropriately enough) and where you create a logos/ directory to hold customm ship logos. I use my gun snail:

gunsnail logo