Page 1 of 1

wanted: script to clean up unitdef files

Posted: 14 Sep 2012, 15:31
by knorke
Seeing the scripts by yanom and Cubex, I thought it might be cool to have a script to clean up unitdef files.

The problem:
In many mods, the tags in units files are basically ordered randomly.
I facepalm every time I open a unit file. (in my mod too :roll: )
ctrl-f all the things?


Random example:
Say you want to edit the movent of that unit then you want to look at:
acceleration, brakeRate maxVelocity and turnRate
Those tags kind of go together in function.
In that file they are dozens of lines apart, that is annoying.

The idea:
Someone make a thingy to neatly reorder the lines like this:

Code: Select all

--Cost--
buildCostMetal = 500,
buildCostEnergy = 0,
buildTime = 25,
--Health--
maxDamage = 1500,
idleAutoHeal = 0,
--Movement--
maxVelocity = 3.0,
Acceleration = 0.5,
BrakeRate = 0.3,
FootprintX = 3,
...
The to-be order could be defined in some config file that lists the tags in the shall-be order.
Inspiration might be the grouping on this page:
http://springrts.com/wiki/Units-UnitDefs

Any unlisted tags can be considered invalide and should be removed. (maybe keep them at the end of the new file, commentated out, for manual checking)

pro tip:
If it was some .lua file that can simply be included in unitdefs_post.lua, then it would be simplest to use: No need to install funny frameworks or figuring out how they work ;)

Re: wanted: script to clean up unitdef files

Posted: 14 Sep 2012, 18:14
by FLOZi
Evil4Zerggin made a python script which s44 used for a long time, but it is for fbi/tdf. It stripped out junk tags, alphabetized and also allowed arbitrary modifiers to numerical values e.g. all LOS ranges doubled (ofc that is mostly done via defs_post now).

( http://spring1944.svn.sourceforge.net/v ... gin/pytdf/ )

Grouping on the wiki page is ok but order is mostly that of the source code with the occasional rearrangement by my whim / perceived utility, alphabetical might be better.

Re: wanted: script to clean up unitdef files

Posted: 14 Sep 2012, 20:04
by PicassoCT
i heavily disagree. alphabetical order is not the correct approach.

Statisticall likelyhood to be tweaked and changed would be the more appropriate sorting criteria.

Additonal Mainfunctions
Speed
Hitpoints
Weapons

Sorted into groups,necessary tags bevor behaviour, behaviour before looks, looks bevor comented out stuff

Re: wanted: script to clean up unitdef files

Posted: 11 Apr 2014, 15:45
by Jools
How about we group them with the same logic that our QWERTY keyboards work: avoid putting often used tags adjacent to that they will not 'jam' (like keyboard keys).