X4 Foundations modding
To allow user of this mod to create their own X4 mod that will allow of adding content based on existing
models to the game.
This repo has a number of scipts to allow:
When you extract the scripts with python3 extract_x4.py --extract
the src
dir should have all the script files
./src/base/index/macros.xml
./src/base/index/components.xml
./src/base/assets/units/*/macros/ship_{arg|par|tel}_*_macro.xml
./src/base/assets/props/SurfaceElements/macros/shield_*_macro.xml
./src/base/assets/props/WeaponSystems/*/macros/*_macros.xml
Note: base games are in /src/base, the dlc files are in /src/egodlc*
see mods/rat2 for example
(work in progress)
Step 1: Create config.py
run ./setup.py
or python3.7 setup.py
(this should create a config.py with paths for present dir, game dir, src dir, mods dir)
Step 2: extract X4 scripts
run python3 extract_x4.py --extract
(this should extract all the scripts/xml from the game cats+dats into src/ dir)
(run python3 extract_x4.py --extract --all
if you plan to want to work with the model files)
Step 3: make modifications
use:
mods/rat2/content.xml
mods/rat2/*.yaml
as a templates to create your own mod
Step 4: compile mod
run python3 compile_mod2.py {your mod name}
(this should read the yaml files and copy the appropriate xml source files,
update them with values in csv, and place them in your mod dir.
It should create the index, macros, components
Step 6: pack your mod
run python3 pack_mod.py {mod name}
(this should take the files in your mods/{mod name}/, copy the files in root dir and
pack the files in index, libraries, mod, and t dirs into your {game dir}/extensions/{mod name}/)
Step 7: run game and verify it works
In the game in Extensions you should see the name of your mod.
If there are any issues look at your Debug Log
(you can assign a key to it in Controls -> General -> Open Debug Log, you can open it without loading any saves, on game start)
Note: if you add a ship or ware, it might not be in the Wharf/Shipyard you are docked at, it depends on the
faction where it’s available (this can be controlled in the libraries/wares.xml)
./setup.py
or python3.7 setup.py
(ubuntu)Written and tested in the following environment
./setup.py
which will try to auto detect your X4 game dir and create config.py./setup.py
doesn’t work, use config.py.sample
to create your own config.py
(adjust paths as necessary)python3 extract_x4.py --extract
to exract the game scripts for most moddingpython3 extract_x4.py --extract --all
(this is necessary for xmf2obj.py)python3 compile_mod.py {your-mod-name}
and in the mods/{your-mod-name} the script will createpython3 pack_mod.py {your-mod-name}
and in your game X4/extensions/ {your-mod-name} dir shouldpip install -r requirements.txt
, then you can run ./run_tests.sh
or ‘./xmf2obj.py —all’xmf2obj.py
you can extract specific xmf files, or run xmf2obj.py --all
to extract all ship models