TEMPLATIZER-PY for Space Empires IV
By Ed Kolis (ekolis@cinci.rr.com)

The Templatizer-PY is a Python-based utility for generating data files for SPace Empires IV or other games from Malfador Machinations using a similar data format.

To run it, download and install a Python distribution from www.python.org, then go to the directory to which you installed this program and type:

templatizer.py

You will then be prompted for an input file and an output file. It is not wise to enter the same file name for both, as the file will be opened first for input and then for output (before it is closed for input), and your data will be lost!

The input file has the same format as the Space Empires IV data file: a *BEGIN* tag, followed by two blank lines, followed by records separated by single blank lines. However, the templatizer will let you use several other methods of defining data:

Python code enclosed in {{{ }}} blocks (where the {{{ and }}} are on separate lines) will be executed before every subsequent record. This is useful for defining global utility functions.

Python code enclosed in {{ }} blocks (where the {{ and }} are on separate lines) will be executed before the next record. This is useful for defining tech grids (see below).

Python code enclosed in { } blocks (where the { and } are on the same line) will be replaced with its return value, except in the special case of the Weapon Damage At Rng field, which is described below.

Tech grids can be defined by use of the special minlevels and maxlevels arrays. By default they are set to [1] and [1] so each input record produces exactly one output record. However if you set them to say [1, 1] and [4, 5] then 20 output records will be generated! Each record will be identical except in that the levels array will be changed, so for instance on the fourth iteration of the above example the levels array will be [1, 4].

The Weapon Damage At Rng field functions somewhat differently from the other fields. Three new variables take effect here: minrange, maxrange, and range. minrange and maxrange can be defined by the user, and will be evaluated as expressions, so you can make a weapon's range dependent on one of its tech grid levels. The range variable is used to get the range for the purpose of calculating damage, as multiple damage values can be calculated from the same formula using different values of range.

For an example, try using test.txt, which contains a sampling of fields: an ordinary numeric field, a damage field, and a field containing both text and template data. Of course, not all fields must contain template data; you may have static fields containing only plain text.

I hope that you enjoy using the templatizer and that it makes your Space Empires IV modding much easier! :-)
-Ed Kolis