Some utility functions

User avatar
Gronank
Colonel
Posts: 2511
Joined: Tue 8 Nov 2011 23:40
Contact:

Some utility functions

Postby Gronank » Sun 7 May 2017 22:01

Editing several items in big lists such as Ammunition,Packs or UniteDescriptor is a big hassle. To get some sort of sensible workflow out of this I created this python script:
https://www.dropbox.com/s/20lztqzvj836fsb/Util.py?dl=0
It contains 3 functions that I find useful.
  • split - takes a string as argument referencing a ndf file. The function spits up the ndf file along every export entry and places all the items into a folder named after the parent ndf file
  • filter - takes 3 arguments, first is a name, the second is a pattern and the third is a folder. It will go into the folder, create a directory with the name and then move all files that match the pattern into that folder. This is useful if you for example have a used the split function on Ammunition.ndf, you can call filter('Smoke','_SMOKE','Ammunition') to extract all smoke ammunition. The pattern can be any regex pattern.
  • merge - puts the file back together, you call the function with the ndf file you want to put together. It replaces the old file with the data found in the split folder, regerdless of the internal file structure of this folder. Importantely, it puts the data back together in the same order as before so that eugens updating scheme doesn't go haywire.

It's not a terribly elegant solution, but it works well enough if you can fiddle a little bit with python.
(does anyone know how to make functions like these more integrated into sublime?)
Image

User avatar
Darkmil
Brigadier
Posts: 3009
Joined: Mon 29 Oct 2012 15:17
Location: Lyon
Contact:

Re: Some utility functions

Postby Darkmil » Sun 7 May 2017 23:25

Thanks a lot !
Image

Who is online

Users browsing this forum: No registered users and 1 guest