Guides/03

Editing records

Create, change, copy and remove records. Apply many changes at once.

Every command on this page saves the plugin. Add --dry-run to test a change first. Without -o, the save replaces the plugin and makes a backup beside it. With -o FILE, the save writes a different file, and --overwrite is necessary when that file exists. See Save rules.

Create and change

esx record create MyMod.esp KYWD --edid MyKeyword
esx record set MyMod.esp edid:MyWeapon 'DNAM\Damage - Base' 42
esx record remove MyMod.esp edid:OldThing

record create fills the new record with the default values from its definition. Set the other fields before you use the record in the game.

Copy

By default, record copy makes an override. Add --as-new to make a new record. esx adds the missing masters. It also copies parent records, such as the CELL of a reference, as overrides.

esx record copy MyMod.esp edid:SourceCell --from Source.esp
esx record copy MyMod.esp edid:SourceCell --from Source.esp --as-new --deep --edid CopiedCell

--deep copies the child groups. It also remaps the references inside the copy.

FormIDs and references

esx record change-formid MyMod.esp edid:MyItem 01000F00
esx record retarget MyMod.esp edid:OldKeyword edid:NewKeyword
esx plugin renumber MyMod.esp

change-formid updates the overrides and all references in the loaded plugins. retarget replaces references to the first record with references to the second.

Deleted and partial records

esx record set-deleted MyMod.esp 0001F4A2 true
esx record set-partial MyMod.esp edid:MyQuest true

Use false as the value to restore the record.

Batch

esx batch runs a list of changes from a JSON file. All changes use one session and one save. If one change fails, esx saves nothing. Use --keep-going to change this behavior.

A batch file can make the records of a mod without a Rhai file. This example makes a weapon from the vanilla .44, with its own ammunition and keyword:

{
  "plugin": "MyMod.esp",
  "ops": [
    { "op": "create", "signature": "KYWD", "edid": "MyFamily" },
    { "op": "copy", "record": "edid:Ammo44", "from": "Fallout4.esm", "as_new": true, "edid": "MyAmmo" },
    { "op": "copy", "record": "edid:44", "from": "Fallout4.esm", "as_new": true, "edid": "MyGun" },
    { "op": "set", "record": "edid:MyGun", "path": "FULL", "value": "My Gun" },
    { "op": "set", "record": "edid:MyGun", "path": "DNAM\\Ammo", "value": "edid:MyAmmo" },
    { "op": "set_native", "record": "edid:MyGun", "path": "DNAM\\Capacity", "value": 6 },
    { "op": "set_flag", "record": "edid:MyGun", "path": "DNAM\\Flags", "flag": "Bolt Action", "value": false },
    { "op": "append", "record": "edid:MyGun", "path": "Keywords\\KWDA", "value": "edid:MyFamily" }
  ]
}
esx batch changes.json --dry-run
esx batch changes.json
Operation Effect
set Set the edit value of each element that the path selects.
set_native Set each selected element’s native value to a number, text or bool.
set_flag Set one named flag with true or clear it with false. The other flags do not change. The result lists the changed flags and all flags that are set.
add Add a member, such as a subrecord, to a record or a struct.
append Add an entry at the end of a list: empty, or a copy of the entry at from. Then set its value and its fields.
remove_element Remove each element that the path selects.
create Make a new record with the default values of its definition, as record create. An optional id gives the record its object ID.
record Make a record from a full tree, in the shape of record show --format json. See A full record as a tree.
copy Copy a record as an override, or as a new record with as_new and edid. An optional id gives the new record its object ID. An optional remove list removes elements, and an optional set map then sets values in the copy.
remove_record Remove a record.
change_formid Change the FormID of a record and of the references to it.
add_masters, clean_masters, sort_masters Change the master list.
clean Remove identical-to-master records and undelete references.

A value edid:Name in a FormID field refers to the record with that editor ID. See Records and paths. Create or copy a record before an operation refers to it. Paths take the entry selectors of Records and paths.

id is the object ID of a new record, with 1 to 6 hexadecimal digits: "id": "000800". The operation fails when a record of the plugin has the ID or when the ID is out of the range of the plugin. Without id, the record gets the next free ID. See Stable object IDs.

append can copy an entry and change it in one operation:

{ "op": "append", "record": "edid:MyMod", "path": "DATA\\Properties",
  "from": "DATA\\Properties\\[Property=Keywords]",
  "fields": { "Value 1": "edid:MyNode" } }

In fields, text is an edit value, and a number or bool is a native value.

A property of an object mod (DATA\Properties) has a value whose type comes from Value Type. With FormID,Int or FormID,Float, Value 1 is a link and takes edid:NAME. This operation gives a new part the keyword HasScope, with no vanilla property to copy:

{ "op": "append", "record": "edid:MyBarrel", "path": "DATA\\Properties",
  "fields": { "Value Type": "FormID,Int", "Function Type": "ADD",
              "Property": "Keywords", "Value 1": "edid:HasScope", "Value 2": 1 } }

The fields apply in the order of the document. Set Value Type first, then Function Type and Property, then the values. When Value 1 comes before Value Type, the operation fails with the hint “set Value Type before Value 1”. A set on Value Type of an entry that exists changes the type of its values in the same way.

Property takes a name only when DATA\Form Type is Weapon, Armor or Non-player character. A copy of a vanilla part has the value. A new part gets it with a set before the first property.

Sorted lists

Some lists are sorted by their values: the keywords of a record (Keywords\KWDA) and the properties of an object mod are two of them. An entry of a sorted list moves when its value changes, so a number index such as [0] can name a different entry after a change.

Select an entry of a sorted list by its value:

{ "op": "set", "record": "edid:MyGun", "path": "Keywords\\KWDA\\[.=edid:WeaponTypePistol]", "value": "edid:MyFamily" }

batch gives two warnings for these lists. The operations run the same with or without a warning.

Code Condition Content
SORTED_LIST_INDEX A path has a number index into a sorted list, and an earlier operation of the same run changed that list: a set or an append on an entry, or a remove_element of an entry at that index or before it. Removals from the last index down give no warning. operation, record, path, index and selected, the value that the index selects now.
LIST_DUPLICATE_ENTRY After a set or an append, a sorted list of FormIDs has one value two times. operation, record, path and value.

Texture hashes of a model

A record that is a copy of a vanilla record has the texture hashes of the vanilla model: MODT beside MODL, MO2T beside MOD2, and the same pair for MOD3, MOD4, MOD5 and the other model paths. The hashes of one model are wrong for another model. When set, set_native, the set map of copy or record set changes a model path, esx removes the hash element beside it. The result of the operation names the element:

{ "path": "Male \\ World Model \\ MOD2 - Model Filename",
  "before": "Armor\\MinutemanUnderArmor\\hatGO.nif", "after": "MyMod\\HatGO.nif",
  "texture_hashes_removed": "Male \\ World Model \\ MO2T - Model Information" }

A remove_element of the hash element after the change still passes, so a records file that has this operation builds as before. To keep the element, add "keep_texture_hashes": true to the operation, or give --keep-texture-hashes to record set. A value that does not change removes nothing.

copy takes a set map with the same value rule. Paths refer to fields in the copy. esx sets their values in document order:

{ "op": "copy", "record": "edid:Ammo44", "from": "Fallout4.esm", "as_new": true, "edid": "MyAmmo",
  "set": { "FULL": "My rounds", "DATA\\Value": 3 } }

A set value can also be a tree, which replaces the content of one element. The element is added when the copy does not have it. remove is a list of paths of elements that the copy must not have; it runs before set. element gives the full content of the copy as one tree.

A full record as a tree

record holds one record as a tree of names and values. The tree has the shape that esx record show --format json prints in data.element, so you can copy a tree from there. Only name, value and children are read.

{ "op": "record", "signature": "FLST", "id": "000810",
  "element": { "children": [
    { "name": "EDID - Editor ID", "value": "MyList" },
    { "name": "FormIDs", "children": [
      { "name": "FormID", "value": "edid:MyFamily" },
      { "name": "FormID", "value": "Fallout4.esm:01F66B (Ammo308Caliber)" }
    ] }
  ] } }
Field Meaning
signature The record type. Not necessary when the tree has Record Header with Signature.
id The object ID. When a record of the plugin has this ID and this type, it gets the tree. Without id, the record is new and gets the next free ID.
parent The parent record of a child record, as in create.
element The tree.
  • The record becomes equal to the tree: esx sets each value, adds each element and each list entry of the tree, and removes what the tree does not have and the record type does not require.
  • A name is the name of record show (EDID - Editor ID), the signature (EDID) or the plain name.
  • A value is an edit value. Flags can be the flag names with , between them.
  • A FormID value can be edid:Name, self:000800 or Fallout4.esm:01F66B. Make a record before a value refers to it. For two records that refer to each other, make the second one with create and its id first, and give it its tree later.
  • In Record Header, the fields Record Flags, Form Version, Version Control Info 1 (4 bytes as hexadecimal text) and Version Control Info 2 (2 bytes) are set. The other header fields are not read.

esx plugin export-records writes these entries from a plugin.

One records file for each build folder

A records file is a batch document that makes the records of a mod. --plugin PATH overrides the document’s plugin value, which you can then omit. A top-level create object makes the plugin if its file does not exist. It accepts the options of plugin create as keys. Each key is optional:

{
  "create": { "masters": ["Fallout4.esm"], "light": true, "esm": false, "author": "Me" },
  "ops": []
}
esx batch records.json --plugin MyMod.esp -o build/MyMod.esp

The new file goes to -o. Without -o, esx uses the plugin path as written. A bare plugin name goes into the --data folder if supplied, or the current directory otherwise. This follows the same rules as plugin create. When the plugin file exists, create does nothing.

In a project folder, put the records files in records/. esx build makes the plugin and applies each file in file name order. Then a records file needs no plugin value and no create object.