[TOOLS] X4 Mod Utilities

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

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

Azalrion
Posts: 66
Joined: Sat, 9. Nov 13, 11:31
x4

[TOOLS] X4 Mod Utilities

Post by Azalrion »

Just a few tools packaged up to hopefully make life a little easier created for my own sanity.

Diff
diff.exe [left - the file to take as the base] [right - the file to take as the changed file] [--out - output file defaults to patch.xml]

This will create an xml file with a valid patch using attributes where possible as the selectors instead of indicies. This is done by comparing the two files and generating the difference between them.

Unpack
unpack.exe [sourcedir - the root where the cat/dat files are] [destdir - where to put the extracted files] [-i/--include - cat files to include, defaults to all in directory (multiple one file per -i)] [-f/--filter - a regex filter to match on files to restrict the output defaults to ^.*(xml|xsd|html|js|css|lua)$]

This will extract all files in either the found cats or the restricted list of cats extract all files that match the filter and write them to the destdir. If the destdir is not empty it will only extract files that are newer. It will create a changelog.txt with all files its written.

https://www.nexusmods.com/x4foundations ... escription
User avatar
alexalsp
Posts: 1896
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [TOOLS] X4 Mod Utilities

Post by alexalsp »

Can you provide an alternative link? :wink:
Azalrion
Posts: 66
Joined: Sat, 9. Nov 13, 11:31
x4

Re: [TOOLS] X4 Mod Utilities

Post by Azalrion »

User avatar
alexalsp
Posts: 1896
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [TOOLS] X4 Mod Utilities

Post by alexalsp »

Thank you. :)
User avatar
alexalsp
Posts: 1896
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [TOOLS] X4 Mod Utilities

Post by alexalsp »

Can examples how it works?

Is this program for win or linux?
The program will generate an error.

All exe the same error.
Spoiler
Show
Image
SpaceCadet11864
Posts: 476
Joined: Tue, 4. Dec 18, 02:14
x4

Re: [TOOLS] X4 Mod Utilities

Post by SpaceCadet11864 »

it appears to be a CLI tool written in python :)

I haven't used it but you would have to run this with cmd.exe in cli

I like it, but can you make it just automatically make and set the directory to "unpacked-${version}" ?? I want to keep them all so I can diff, since I wont have the prior version cat files anymore anyway.

You can grab the version number from "version.dat"

I wrote this in powershell which does essentially the same thing but uses XR tool:

Code: Select all

$catFiles = Get-ChildItem -Path "$(Get-Location)\*" -include "*.cat"  -exclude "*sig*"
$currentVersion = $(Get-Content .\version.dat)
$unpackDir = "$(Get-Location)\unpacked-$currentVersion"

$includePaths = $catFiles.Name

New-Item -Path $unpackDir -ItemType Directory

.\XRCatTool.exe -in $includePaths -out $unpackDir -exclude assets

EDIT: cleaned up code
Last edited by SpaceCadet11864 on Tue, 11. Dec 18, 16:40, edited 1 time in total.
Azalrion
Posts: 66
Joined: Sat, 9. Nov 13, 11:31
x4

Re: [TOOLS] X4 Mod Utilities

Post by Azalrion »

SpaceCadet11864 wrote: Tue, 11. Dec 18, 16:22 it appears to be a CLI tool written in python :)

I haven't used it but you would have to run this with cmd.exe in cli

I like it, but can you make it just automatically make and set the directory to "unpacked-${version}" ?? I want to keep them all so I can diff, since I wont have the prior version cat files anymore anyway.

You can grab the version number from "version.dat"

I wrote this in powershell which does essentially the same thing but uses XR tool:

Code: Select all

$catFiles = Get-ChildItem -Path "$(Get-Location)\*" -include "*.cat"  -exclude "*sig*"
$currentVersion = $(Get-Content .\version.dat)
$unpackDir = "$(Get-Location)\unpacked-$currentVersion"
$unpackCmd = "$(Get-Location).\XRCatTool.exe"
$includePaths = $catFiles.Name
Write-Output "catFiles: $catFiles"
Write-Output "Include Paths: $includePaths"
Write-Output "unpackDir: $unpackDir"

New-Item -Path $unpackDir -ItemType Directory

.\XRCatTool.exe -in $includePaths -out `"$unpackDir`" 
Yep, a very hacky aweful mangled code CLI tool packed using pyinstaller.

I could add in versioning, I'll add in a switch to append the version to destdir if its set.
SpaceCadet11864
Posts: 476
Joined: Tue, 4. Dec 18, 02:14
x4

Re: [TOOLS] X4 Mod Utilities

Post by SpaceCadet11864 »

nice!

I updated my powershell script that basically gets all of the .cat files and unpacks them, but it takes out assets. it puts them in a directory called "unpacked-{version}"
Spoiler
Show

Code: Select all

$catFiles = Get-ChildItem -Path "$(Get-Location)\*" -include "*.cat"  -exclude "*sig*"
$currentVersion = $(Get-Content .\version.dat)
$unpackDir = "$(Get-Location)\unpacked-$currentVersion"

$includePaths = $catFiles.Name

New-Item -Path $unpackDir -ItemType Directory

.\XRCatTool.exe -in $includePaths -out $unpackDir -exclude assets

.Sinistral
Posts: 5
Joined: Sat, 8. Dec 18, 11:21

Re: [TOOLS] X4 Mod Utilities

Post by .Sinistral »

Not certain it makes much difference, but just thought i'd say, the hash shown in the base game .cat files is MD5 not SHA :D
Or, at least the ones i checked anyway lol :P
Azalrion
Posts: 66
Joined: Sat, 9. Nov 13, 11:31
x4

Re: [TOOLS] X4 Mod Utilities

Post by Azalrion »

Ah so it is, and so is the windows spec. Not really using the packer atm but ill fix that.

Return to “X4: Foundations - Scripts and Modding”