Skip to content

Quick manual

Bernd Kosmahl edited this page Jul 15, 2024 · 2 revisions

Quick install manual:

  • Clone this somewhere and symlink game/extensions/sn_mod_support_apis to the folder sn_mod_support_apis from the checkout (move an existing folder outside of extensions!)
  • Install lua5.1-socket on your system (lua5.4-socket does NOT work)
  • symlink /lib64/lua/5.1/socket/* to game/ui/core/lualibs/ OR game/extensions/sn_mod_support_apis/lua/c_library/socket/ - path depends on your system
  • Grab any .cat and .dat files (subst_01.cat, subst_01.dat, and so on) from the official sn_mod_support_apis extension and drop them into the folder /sn_mod_support_apis/ too [1].
  • Start the game and go to Options Menu => Extension Options => Named Pipes API and enter the ABSOLUTE path to your savegame folder at "Pipe Prefix Linux". Mine is /home/beko/.config/EgoSoft/X4/save - ymmv.

That's it. Pipe servers should spawn on new/loaded games in that save folder, e.g.: ~/.config/EgoSoft/X4/save/x4_python_host.xml

Why the save folder? It's the only folder I can unlink files from Lua. That's also why it needs the file ending ".xml" even when it's not an xml. It's a loophole in the DeleteSavegame() function. If you don't adjust this it will spawn in /tmp and has to be deleted manually after each tear-down!

For a quick test you can just tail the socket e.g. with netcat: nc -U ~/.config/EgoSoft/X4/save/x4_external_game.xml where new messages from extensions, like X4-External-App, should show up.

Most documentation so far is inline in linpipe.lua, on the todo list.

[1] This is basically just the packaged ui/ folder but it requires the X Catalog Tool only available for Windows and while I know how the files can be created manually I still have to write a script to do so. The new menu options will not appear without this step.

Debug

X4 has various command line parameters. Keep in mind that the sockets are spawned on load so there won't be much to see from the game main menu. To get a full debug log run it like this:

Steam

%command% -debug all -logfile debuglog.txt

GOG

From within the folder X4_Foundations/game run:

./X4 -debug all -logfile debuglog.txt

A log file will be created next to your save folder.

Logfile

This is an example how to tail said log and limit it somewhat to get only Linux_Pipe related output:

tail -f ~/.config/EgoSoft/X4/6336528/debuglog.txt | grep Lin

A successful log might look like this:

[=ERROR=] 21530.78 Looks like Linux, loading linpipe
[=ERROR=] 21531.00 [LinPipe] looking for socket lib in the following paths: extensions/sn_mod_support_apis/lua/c_library/?.so;?.so;ui/core/lualibs/?.so
[=ERROR=] 21531.00 [LinPipe] socket/core.so was loaded
[=ERROR=] 21531.00 [LinPipe]: LuaSocket 3.0.0 found, debug support is disabled
[=ERROR=] 21531.00 [LinPipe] socket/unix.so was loaded
[=ERROR=] 21531.00 [LinPipe]: Preparing new socket x4simpit
[=ERROR=] 21531.00 [LinPipe]: Lingering sockets in savegame folder are deleted automatically
[=ERROR=] 21531.00 [LinPipe]: Creating new socket server at /home/beko/.config/EgoSoft/X4/save/x4simpit.xml
[=ERROR=] 21531.00 [LinPipe]: Struct ready x4simpit
[=ERROR=] 21531.00 [LinPipe]: Returning pipe x4simpit
[=ERROR=] 21531.00 [LinPipe] looking for socket lib in the following paths: extensions/sn_mod_support_apis/lua/c_library/?.so;?.so;ui/core/lualibs/?.so
[=ERROR=] 21531.00 [LinPipe] socket/core.so was loaded
[=ERROR=] 21531.00 [LinPipe]: LuaSocket 3.0.0 found, debug support is disabled
[=ERROR=] 21531.00 [LinPipe] socket/unix.so was loaded
[=ERROR=] 21531.00 [LinPipe]: Preparing new socket x4_python_host
[=ERROR=] 21531.00 [LinPipe]: Lingering sockets in savegame folder are deleted automatically
[=ERROR=] 21531.00 [LinPipe]: Creating new socket server at /home/beko/.config/EgoSoft/X4/save/x4_python_host.xml
[=ERROR=] 21531.00 [LinPipe]: Struct ready x4_python_host
[=ERROR=] 21531.00 [LinPipe]: Returning pipe x4_python_host
[=ERROR=] 21531.10 [Linux_Pipe][x4_python_host] Preparing new coroutine for server x4_python_host
[=ERROR=] 21531.10 [Linux_Pipe][x4simpit] Preparing new coroutine for server x4simpit
[=ERROR=] 21531.25 [Linux_Pipe][x4_python_host] New connection unixstream{client}: 0x7fa827e7e040 for x4simpit
[=ERROR=] 21531.25 [Linux_Pipe][x4_python_host] Accepted new connection unixstream{client}: 0x7fa827e7e040
[=ERROR=] 21531.27 [Linux_Pipe][x4simpit] Writing to client unixstream{client}: 0x7fa827e7e040
[=ERROR=] 22431.98 [Linux_Pipe][x4simpit] Wrote 398 characters to client unixstream{client}: 0x7fa827e7e040
[=ERROR=] 22431.98 [Linux_Pipe][x4_external_game] [GC] Removing server socket coroutine
[=ERROR=] 22431.98 [Linux_Pipe][x4_external_game] [GC] Deleted socket x4_external_game
[=ERROR=] 22431.98 [Linux_Pipe][x4_python_host] [GC] Removing server socket coroutine
[=ERROR=] 22431.98 [Linux_Pipe][x4_python_host] [GC] Deleted socket x4_python_host
[=ERROR=] 22431.98 [Linux_Pipe][x4simpit] [GC] Removing server socket coroutine
[=ERROR=] 22431.98 [Linux_Pipe][x4simpit] [GC] Deleted socket x4simpit
Clone this wiki locally