Tes4Mod:Wrye Bash Mod Elements

Some of the mod record structure data here is given in Wrye Bash mod element structure. This is simply a dump of Bash's code. However, since the dump is basically a template definition, it's (relatively) easier to read. Ideally these should be converted to regular format. But for now, the dump is trivial to do.

Example
What follows is the class definition for a FACT (Faction) record. Flag field prototypes are usually defined here (usually as 'flags'), and the data structure is defined by a MelSet object. Read and write operations are performed by the parent class, based on the template defined by the MelSet object. But as far as definition goes, all you care about is the MelSet structure, plus flags field. Note that elements are listed in Oblivion.esm subrecord order. 

By the way, in python bare strings at the beginning of a class or structure are documentation strings, not code. Also, '#' marks the beginning of a comment field. On to definitions...

 

This tranlates to:
String eid from EDID record. Defaults to empty.
String full from FULL record. Defaults to empty.
Array relations from XNAM records
Formid faction. Defaults to none.
int mod. Defaults to 0.
flags (defined on fourth line) flags taken from DATA record, read as unsigned byte. Defaults to unsigned int 0. 
float crimeGoldMultiplier from CNAM record. Defaults to 1.0.
Array ranks
int rank taken from RNAM record. defaults to 0
Stringr male taken from MNAM record. Default to empty/none.
String female taken from FMAN record. Defaults to empty/none.
Path string insignia taken from INAM record. Defaults to empty/none.

Flags
You can read the flag field bits from arguments to Flags.getNames(). If the names are bare strings, then they correspond to bits 0,1,2, etc. in order. If the flag argument is a tuple (e.g. (16,'hideRings'), then it's saying that bit 16 is 'hideRings'.

Mod Elements
MelBase 
 
A raw data field. Not written if value == None.

MelFormid 
 
A formid field. Not written if value == None.

MelFormids 
 
An array of formids. 

MelString 
 
A zero terminated string field. Not written if value == None.

MelStruct 
 
A structure record. Format is as given by Python:struct. E.g.,   is: unsigned 32-bit int, float, signed 32-bit int. The elements are additional arguments with one argument per unpacked structure element. A full element is 3 element tuple: (action,attribute,default). If default is not defined, then it is taken as zero. The action can either be 'FID' to indicate a formid or function or class name which will take the unpacked data as an element. Currently, when present this is always a flags prototype. If there is no action, then the action field is skipped. If there is only the attribute, then it can be presented just the attribute name, rather than the tuple.

MelStructs 
 
An array of structures. This exactly the same as the MelStruct, except structures are stored in an object array with the specified attribute. 

MelGroup 
 
This is a like subset of the MelSet. It's a group of separate mod file subrecords that act as a single attribute. The subelements are themselves Mod Elements (e.g., MelString, MelStruct), and are typically presented on separate lines. The subelements are stored in a single object as 'attribute'. By default attribute is empty. If None of the subelements appear, then the structure will remain empty and will not be printed.

MelGroups 
 
Same as MelGroup, only attribute is now an array of groups.

MelModel 
 
A predefined MelGroup consisting (for index = 0) of 
 
If index == 2,3,4, then the corresponding types are used (MOD2,MO2B, etc.)