[TOOLS] X4 Mod Utilities
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 66
- Joined: Sat, 9. Nov 13, 11:31
[TOOLS] X4 Mod Utilities
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
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
-
- Posts: 1896
- Joined: Fri, 18. Jul 14, 05:28
Re: [TOOLS] X4 Mod Utilities
Can you provide an alternative link? 

-
- Posts: 66
- Joined: Sat, 9. Nov 13, 11:31
-
- Posts: 1896
- Joined: Fri, 18. Jul 14, 05:28
Re: [TOOLS] X4 Mod Utilities
Can examples how it works?
Is this program for win or linux?
The program will generate an error.
All exe the same error.

Is this program for win or linux?
The program will generate an error.
All exe the same error.
Spoiler
Show

-
- Posts: 476
- Joined: Tue, 4. Dec 18, 02:14
Re: [TOOLS] X4 Mod Utilities
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:
EDIT: cleaned up code

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
Last edited by SpaceCadet11864 on Tue, 11. Dec 18, 16:40, edited 1 time in total.
-
- Posts: 66
- Joined: Sat, 9. Nov 13, 11:31
Re: [TOOLS] X4 Mod Utilities
Yep, a very hacky aweful mangled code CLI tool packed using pyinstaller.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`"
I could add in versioning, I'll add in a switch to append the version to destdir if its set.
-
- Posts: 476
- Joined: Tue, 4. Dec 18, 02:14
Re: [TOOLS] X4 Mod Utilities
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}"
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
-
- Posts: 5
- Joined: Sat, 8. Dec 18, 11:21
Re: [TOOLS] X4 Mod Utilities
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 
Or, at least the ones i checked anyway lol

Or, at least the ones i checked anyway lol

-
- Posts: 66
- Joined: Sat, 9. Nov 13, 11:31
Re: [TOOLS] X4 Mod Utilities
Ah so it is, and so is the windows spec. Not really using the packer atm but ill fix that.