ModSync/For guide authors/Instruction format reference

Instruction format reference

Every field ModSync reads from an instruction file, what each one means, what it accepts, and which mistakes stop a guide from validating. Read Instruction files first if you have not written a guide before.

File structure

A structured guide has two parts. The build metadata holds text about the whole build, such as the preamble shown before installation. The component list holds one entry per mod. Each component can carry its own instruction steps and its own options.

The component list is named thisMod. Components is accepted as an alias. The four formats lay the same data out differently:

FormatLayoutBuild metadata
TOMLA [metadata] table, then one [[thisMod]] table per component. Steps go in [[thisMod.Instructions]], options in [[thisMod.Options]], and an option's steps in [[thisMod.Options.Instructions]].Kept
YAMLAn optional metadata document starting --- with a # Metadata line, then one --- document per component.Kept
JSONAn array of component objects. An object with a thisMod array is also read.Not written by ModSync
XMLA <ModSync> root with one <ModComponents> element per component. Repeated values such as Category repeat as elements.Not written by ModSync

Because ModSync writes JSON and XML with components only, build metadata has to live in TOML or YAML. The snippets below show the same component in each format.

[[thisMod]]
Guid = "11111111-1111-1111-1111-111111111111"
Name = "Sample textures"
IsSelected = true

[[thisMod.Instructions]]
Action = "Copy"
Source = ["<<modDirectory>>/sample.tga"]
Destination = "<<kotorDirectory>>/Override"
[
  {
    "Guid": "11111111-1111-1111-1111-111111111111",
    "Name": "Sample textures",
    "IsSelected": true,
    "Instructions": [
      {
        "Action": "Copy",
        "Source": ["<<modDirectory>>/sample.tga"],
        "Destination": "<<kotorDirectory>>/Override"
      }
    ]
  }
]
---
# Metadata
fileFormatVersion: "2.0"
title: Sample build
---
Guid: 11111111-1111-1111-1111-111111111111
Name: Sample textures
IsSelected: true
Instructions:
  - Action: Copy
    Source:
      - "<<modDirectory>>/sample.tga"
    Destination: "<<kotorDirectory>>/Override"
<ModSync>
  <ModComponents>
    <Guid>11111111-1111-1111-1111-111111111111</Guid>
    <Name>Sample textures</Name>
    <IsSelected>true</IsSelected>
    <Instructions>
      <Action>Copy</Action>
      <Source>&lt;&lt;modDirectory&gt;&gt;/sample.tga</Source>
      <Destination>&lt;&lt;kotorDirectory&gt;&gt;/Override</Destination>
    </Instructions>
  </ModComponents>
</ModSync>

Field names are matched without regard to capital letters in most places, but write them exactly as shown in the tables below. Two keys are stricter: Instructions must match exactly in TOML, and Overwrite must match exactly in TOML and YAML. A lowercase overwrite in those formats is ignored, so the action's default applies.

Build metadata fields

These keys sit in the [metadata] table (TOML) or the # Metadata document (YAML). Each one is optional.

KeyTypeRequired?Meaning
fileFormatVersiontextNoWritten as "2.0" when ModSync saves a guide. In YAML, its presence marks a document as metadata.
titletextNoFree text kept with the guide. The code I read does not use it during install.
lastModifieddate and timeNoWhen the guide was last changed. A value that cannot be read as a date is dropped on save with a warning. TOML saves it as a local date and time. A capitalised LastModified is ignored in TOML, and read as lastModified in YAML.
preambleContentrich textNoShown on the desktop's preamble page, before installation starts.
epilogueContentrich textNoShown on the desktop's finish page, after installation.
widescreenWarningContentrich textNoWarning shown on the desktop's widescreen page, with a Copy button.
aspyrExclusiveWarningContentrich textNoNotice shown on the desktop's Aspyr notice page.
installationWarningContentrich textNoKept and saved with the guide. I did not find a page that displays it.

The five rich text keys are also accepted with a capital first letter, such as PreambleContent.

Component fields

Each entry in thisMod is a component. Options use the smaller set listed under Options and choices.

KeyTypeRequired?Meaning
GuidGUID textYesIdentifies the component. Must be unique across all components and options. Letter case does not matter.
NametextYesThe mod's name, shown in the mod list. Blank names are refused.
AuthortextNoThe mod's author.
Descriptionrich textNoMain description of the mod.
DescriptionSpoilerFreerich textNoUsed instead of Description when spoiler-free mode is on. The same pattern applies to Directions, DownloadInstructions, UsageWarning and Screenshots.
Directionsrich textNoInstallation directions for the player.
DownloadInstructionsrich textNoHow the player obtains the mod's files.
UsageWarningrich textNoA warning the player should read before using the mod.
Screenshotsrich textNoScreenshot text shown with the component.
HeadingtextNoSection heading used when the guide is exported to Markdown.
TiertextNoPriority. Text containing essential, recommend, suggest or option is stored as 1 - Essential, 2 - Recommended, 3 - Suggested or 4 - Optional. Other text is kept as typed. The desktop's tier selection buttons use it.
Categorytext or listNoCategories for filtering. A single text value is read as a one-item list.
Languagetext or listNoLanguages the mod supports, shown with the component.
InstallationMethodtextNoFree text describing how the mod installs, for example Executable Installer. Shown in the summary as "uses ...". It does not change what is installed.
ExcludedDownloadskept as writtenNoAccepted and saved. I did not find code that acts on it.
DependenciesGUID text or listNoComponents (or immediate options) that must be selected. Validation warns when one is not selected. Install refuses the selection.
RestrictionsGUID text or listNoComponents that cannot be installed together with this one. If one of them is selected, validation reports an error and install refuses.
InstallBeforeGUID text or listNoThis component installs before the listed ones. Ignored in Markdown guides.
InstallAfterGUID text or listNoThis component installs after the listed ones. Ignored in Markdown guides.
IsSelectedbooleanNoWhether the component is selected by default. A missing value means false. If a non-Markdown file selects nothing, every component is selected on load.
Instructionslist of stepsNoThe steps that install the mod, run in order. See Instructions.
Optionslist of optionsNoChoices the player can pick. See Options and choices.
ResourceRegistrymapNoDownload links and their file details, keyed by URL. See Archive and download fields.
ModLink, ModLinkFilenameslegacyNoOlder forms of download links. They are moved into ResourceRegistry when the guide loads.
WidescreenOnlybooleanNoMarks a widescreen-only component. See Game detection and flags.
AspyrExclusivebooleanNoMarks a component that only the Aspyr version of KOTOR 2 can use. See Game detection and flags.

Boolean values. true and false are the usual forms. A number other than zero is true. Text is true only when it reads true, in any capitalisation. Anything else is false.

Lists. Where a list is expected, a single text value is also accepted and read as a one-item list.

Unknown keys. Keys the model does not recognise on a component are kept as metadata and saved again. Unknown keys inside a step are ignored by the loader.

Options and choices

An option is a choice the player can make within a component, such as an alternate texture set. Options sit under the component in Options. Their fields are:

KeyTypeRequired?Meaning
GuidGUIDYesIdentifies the option. A Choose step names options by this value, so give each option a real GUID.
NametextYesThe option's name, shown to the player.
DescriptiontextNoShown with the option.
IsSelectedbooleanNoThe option's default choice.
DependenciesGUID text or listNoSame meaning as on a component.
RestrictionsGUID text or listNoSame meaning as on a component.
Instructionslist of stepsNoSteps that run only when the option is chosen.
  • An option has no Author, Category, Tier or Language of its own.
  • A Choose step in the component's Instructions lists the options to apply. Only selected options run, in the order the options are declared.
  • An entry that names no option stops the install with an "Unknown option" error. Options are named by GUID only, in any letter case.
  • Only the immediate options of a component can be named by a Dependencies or Choose entry. Options of options are not offered for selection.
  • On load, an option is dropped when it is unselected, has no relations, is not named anywhere, and has exactly the same steps as an earlier option. Markdown guides are not deduplicated.

Instructions

Each step is one table in a component's Instructions list (or in an option's list). Steps run in order. These fields apply to every action:

KeyTypeRequired?Meaning
Actiontext or numberYesThe action to run. See the list below. An unrecognised name loads as no action and fails validation with "Action cannot be null".
Sourcetext or listDepends on actionFiles, folders or archives the action works on. A path with no placeholder is read as relative to <<modDirectory>>.
DestinationtextDepends on actionA folder, or a new file name for Rename. Must start with a placeholder when it is a path.
ArgumentstextDepends on actionExtra text whose meaning depends on the action.
OverwritebooleanNoWhat to do when a target file already exists. Defaults to true, except for Delete, which defaults to false.
DependenciesGUID text or listNoThe step runs only when all of these are selected.
RestrictionsGUID text or listNoThe step is skipped when any of these is selected.
GuidtextNoAn optional identifier for the step, used by the desktop editor. The install does not depend on it.
ParentGUID textNoWritten as the GUID of the option that owns the step. The install does not read it.

Action names are matched without regard to capitals. TSLPatcher and HoloPatcher are accepted as names for Patcher. A number is also accepted, as its position in this list counting from 0: 1 Extract, 2 Execute, 3 Patcher, 4 Move, 5 Copy, 6 Rename, 7 Delete, 8 DelDuplicate, 9 Choose, 10 Run, 11 CleanList, 12 CreateDirectory.

The actions are listed below in the order they are described. Path placeholders are explained under Path rules.

Actions

Extract

Unpacks an archive into a folder with the archive's name, placed next to the archive. Supported formats are ZIP, 7z, RAR, TAR, GZip and 7z self-extracting archives. Files already in that folder are replaced whatever Overwrite says.

FieldUse
SourceThe archive to unpack, under <<modDirectory>>. Wildcards are allowed.
DestinationLeave empty. Validation reports an error when it is set.
ArgumentsNot used.

Validation reports "Missing Required Archives" when a component's base steps have an Extract with no matching archive.

[[thisMod.Instructions]]
Action = "Extract"
Source = ["<<modDirectory>>/Sample Textures*.zip"]

Copy

Copies matching files into the destination folder. Subfolders are flattened: each file lands directly in the destination.

FieldUse
SourceFiles to copy. Paths may use a placeholder and wildcards.
DestinationThe folder to copy into. Must start with a placeholder. Validation reports "Destination cannot be found!" when the folder is missing and cannot be created.
OverwriteDefaults to true. When false, a file already in the destination is skipped with a warning.
[[thisMod.Instructions]]
Action = "Copy"
Source = ["<<modDirectory>>/Textures/*.tga"]
Destination = "<<kotorDirectory>>/Override"
Overwrite = false

Move

Works like Copy, then deletes each source file once it has been copied.

FieldUse
SourceFiles to move. Paths may use a placeholder and wildcards.
DestinationThe folder to move into. Same rules as Copy.
OverwriteDefaults to true. When false, a file already in the destination is skipped with a warning. A file that would be moved onto itself is skipped or refused in the same way.
[[thisMod.Instructions]]
Action = "Move"
Source = ["<<modDirectory>>/Extra/*.utc"]
Destination = "<<kotorDirectory>>/Override"

Rename

Renames matching files inside their own folder.

FieldUse
SourceThe file or files to rename. Paths may use a placeholder and wildcards.
DestinationThe new file name only. It cannot contain a folder, a placeholder, or wildcard characters, and it must be a valid Windows file name.
OverwriteDefaults to true. When false and the new name is already taken, the other files are still renamed and the step then fails.
[[thisMod.Instructions]]
Action = "Rename"
Source = ["<<kotorDirectory>>/Override/oldname.tga"]
Destination = "newname.tga"

Delete

Deletes the matching files. Folders are never deleted, and a folder matched by a pattern deletes nothing beneath it.

FieldUse
SourceFiles to delete. Paths may use a placeholder and wildcards.
DestinationLeave empty. Validation reports an error when it is set.
OverwriteDefaults to false. With false, a missing file produces a warning and the step continues. With true, a missing file fails the step.

A Delete with no Source does nothing, unless Overwrite is true, in which case it fails.

[[thisMod.Instructions]]
Action = "Delete"
Source = ["<<kotorDirectory>>/Override/old_texture.tga"]

DelDuplicate

Removes one copy of a file when the same name exists with another listed extension in the same folder. The folder's subfolders are checked separately, one folder at a time.

FieldUse
SourceThe extensions to compare, such as ".tga" and ".tpc". When empty, .dds, .tpc and .tga are used.
DestinationThe folder to check. It must already exist.
ArgumentsThe extension to remove when a duplicate is found, such as ".tpc". When empty, files with no extension are the ones removed.

The demo guide uses it to remove a .tpc when a .tga with the same name is present.

[[thisMod.Instructions]]
Action = "DelDuplicate"
Source = [".tga", ".tpc"]
Destination = "<<kotorDirectory>>/Override"
Arguments = ".tpc"

CleanList

Reads a comma-separated list file and deletes the files it names for mods that are selected. Each row starts with a mod name followed by the file names to delete. A row applies when its mod name matches the name of a selected component. Matching is looser than exact equality: the rules accept prefix, substring and token matches (see the CleanList section of COMPATIBILITY.md for the details).

FieldUse
SourceThe list file. Every Source must exist, and the first one is the file that is read.
DestinationThe folder the listed files are in. It must already exist.
ArgumentsNot used.
[[thisMod.Instructions]]
Action = "CleanList"
Source = ["<<modDirectory>>/Cleanup/cleanlist.txt"]
Destination = "<<kotorDirectory>>/Override"

Patcher

Runs a TSLPatcher-style patch. The built-in OdyPatcher library is used by default. A player can instead choose an external patcher program, which needs their permission.

FieldUse
SourceExactly one path under <<modDirectory>>, naming the patch's file or folder. For a file, the folder it sits in is used. Wildcards are not allowed.
DestinationLeave empty, or use <<gameDirectory>>. The patch always runs against the game folder, and validation reports any other value.
ArgumentsExtra options for the patcher, usually the name of the INI file it should read, such as changes.ini.
[[thisMod.Instructions]]
Action = "Patcher"
Source = ["<<modDirectory>>/Patch"]
Destination = "<<gameDirectory>>"
Arguments = "changes.ini"

Execute and Run

Execute and Run do the same thing: they start a program directly, without a shell. The program must exist under <<modDirectory>> or <<kotorDirectory>>. Running it needs the player to allow external programs.

FieldUse
SourceThe program to start. Every Source is resolved before any program starts.
DestinationNot used.
ArgumentsThe command line passed to the program. It is split the way Windows splits command lines, so group values with double quotes. Placeholders are expanded inside it, in any capitalisation. An unknown placeholder stops the step.
[[thisMod.Instructions]]
Action = "Run"
Source = ["<<modDirectory>>/Tools/patch.exe"]
Arguments = "/quiet"

Choose

Applies the options the player selected. Its Source lists the GUIDs of the options it covers. Only the selected ones run, in the order the options are declared on the component.

FieldUse
SourceThe GUIDs of options, one per entry. A single text value separated by commas or semicolons is also accepted.
DestinationLeave empty. Validation reports an error when it is set.
ArgumentsNot used.
[[thisMod.Instructions]]
Action = "Choose"
Source = ["22222222-2222-2222-2222-222222222222"]

CreateDirectory

Creates one new folder. Only the last part of the path is created, so its parent folder must already exist. The name cannot contain wildcard characters.

FieldUse
SourceMust be empty.
DestinationThe folder to create, starting with a placeholder. It cannot be a root folder itself.
ArgumentsMust be empty.
[[thisMod.Instructions]]
Action = "CreateDirectory"
Destination = "<<kotorDirectory>>/Override/Sample"

Archive and download fields

Download information lives in ResourceRegistry, a map keyed by download URL. Each entry is an object with the fields below. Only the first three are needed for peer sharing, and the hash also lets ModSync check a download.

KeyTypeMeaning
ContentHashSHA25664 hexadecimal digitsThe expected SHA-256 of the archive. A download that does not match is not accepted. Peer sharing also requires it.
Magnettext starting magnet:?xt=urn:btih:A BitTorrent magnet link for the same archive. Used with ContentHashSHA256 for peer downloads. Without the hash, peers are not used.
TorrentInfobase64 textThe torrent's metadata. ModSync checks it against the magnet link's hash. Optional when the magnet link carries a display name.
Filesmap of filename to true, false or nullWhich files from a download page to use. false excludes a file. true or null allows it.
FileSizenumberThe file's size in bytes. Legacy entries use 0.
ContentKey, MetadataHashtextIdentity values for the entry. Legacy entries get a SHA-1 of the URL.
HandlerMetadatamapState kept for the download handler. Leave it as {}.
PrimaryUrltextLegacy. Its value becomes the entry's key when the guide loads, and the field is then removed.
FirstSeen, LastVerifiedkept as writtenKept with the entry. I could not confirm what the installer does with them.
[[thisMod]]
Guid = "11111111-1111-1111-1111-111111111111"
Name = "Sample textures"

[thisMod.ResourceRegistry."https://example.com/sample-textures"]
ContentHashSHA256 = "0000000000000000000000000000000000000000000000000000000000000000"
Magnet = "magnet:?xt=urn:btih:0000000000000000000000000000000000000000&dn=sample.zip"
Files = { "sample.zip" = true }

The older ModLink and ModLinkFilenames component keys still load. They are merged into ResourceRegistry, and newer entries take precedence.

Placeholder values above are examples. A real hash must be the SHA-256 of the actual archive, and a real magnet link must carry the torrent's own hash.

Path rules

Paths start from a placeholder, so the same guide works on every computer. The placeholders are:

PlaceholderPoints to
<<modDirectory>>The folder that holds the player's downloaded mod archives.
<<kotorDirectory>>The player's game folder.
<<gameDirectory>>The same folder as <<kotorDirectory>>. Both spellings work.
  • Spelling. In Source and Destination, write the placeholder exactly as shown, including capitals. A placeholder in another capitalisation fails. Inside Arguments, any capitalisation works.
  • Separator. The placeholder must be followed by / or \, or stand alone. Either slash works after it.
  • No placeholder. A Source with no placeholder is read as relative to <<modDirectory>>. A Destination with no placeholder is refused.
  • Wildcards. * (any run of characters) and ? (one character) work in Source for the file actions. They are refused in Destination, in a Rename file name, and in a Patcher Source. Square brackets are not allowed in Destination paths.
  • Always refused. Absolute paths, drive letters (a colon in any part), .. parts, the characters < > | ", parts ending in a space or a dot, and Windows device names: CON, PRN, AUX, NUL, CONIN$, CONOUT$, and COM or LPT followed by 0 to 9 (including the superscript digits 1, 2 and 3).
  • Links and special files. A path that passes through a symbolic link is refused, and so is a special file as a source. The game folder and the mod folder must not overlap, and neither can be a drive root.
  • Download staging. A path into a Peer download staging folder (named .peer-...part) inside the mod folder is refused.

Validation rules

Validation checks a guide without installing it. Run it with modsync validate before you publish a guide. The checks fall into three groups.

Loading the file

  • The guide has no components: it fails to load.
  • A component or option has no Guid or no Name.
  • Two components or options share a GUID, ignoring letter case.
  • The file is larger than 8 MiB, or it cannot be parsed as the format it claims to be.
  • A Source or Destination path is refused under the path rules.

Selection and order

  • Nothing is selected: "Select at least one component".
  • A selected component depends on a component that is not selected: install refuses ("requires selected component"). Validation shows the same problem as a warning.
  • A selected component is restricted against another selected component: validation reports an error, and install refuses.
  • An InstallBefore or InstallAfter entry names a component that does not exist, names the component itself, or forms a cycle. These fail validation and install, even for components that are not selected. Markdown guides ignore these two fields.

Steps

  • A step with no action fails with "Action cannot be null".
  • An Extract with no matching archive fails with "Missing Required Archives".
  • When a component has archives, a <<modDirectory>> Source that is not inside one of them fails with "Failed to find '...' in any archives!". Game folder Sources are not checked this way.
  • A Copy, Move, DelDuplicate or CleanList whose Destination folder cannot be found fails with "Destination cannot be found!".
  • Destination set on Extract, Choose or Delete is an error. A Patcher Destination other than <<gameDirectory>> is an error.
  • A Choose entry that names no option stops the install.

Validation also reports warnings that do not stop the install: a file that already exists when Overwrite is false, a Delete target that is missing, and a tslpatcher.exe used in a Source without the Patcher action.

What validation checks, by stage

StageWhat it checks
EnvironmentThe game and mod folders exist and can be written to, and the game folder holds no two names that differ only by capitals.
ConflictsRestriction conflicts (errors) and missing dependencies (warnings).
Install orderThe InstallBefore and InstallAfter rules above.
Component validationEach selected component's archives, Source paths and Destination folders.
FOMOD configurationArchives that use a FOMOD installer have their choices configured.
Dry runEach step is simulated in order, so a step that would fail on a file that is not there is reported.

Game detection and flags

ModSync identifies the installed game from its files. It recognises three kinds of install: KOTOR 1, KOTOR 2 (legacy), and KOTOR 2 (Aspyr). An install is treated as Aspyr when its override folder holds at least about 70 percent of the Aspyr-specific files it checks for. If the game folder contains a steamassets folder with an override folder and either dialog.tlk or chitin.key, that folder is used as the install root.

  • AspyrExclusive (boolean, in the component). The component can only be selected on the Aspyr version of KOTOR 2. On any other install it is deselected.
  • WidescreenOnly (boolean, in the component). When the installer runs in phases, widescreen-only components are installed after the base build, in their own phase. The direct Markdown install skips them, along with any component named 4GB Patcher.