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:
| Format | Layout | Build metadata |
|---|---|---|
| TOML | A [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 |
| YAML | An optional metadata document starting --- with a # Metadata line, then one --- document per component. | Kept |
| JSON | An array of component objects. An object with a thisMod array is also read. | Not written by ModSync |
| XML | A <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><<modDirectory>>/sample.tga</Source>
<Destination><<kotorDirectory>>/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.
| Key | Type | Required? | Meaning |
|---|---|---|---|
fileFormatVersion | text | No | Written as "2.0" when ModSync saves a guide. In YAML, its presence marks a document as metadata. |
title | text | No | Free text kept with the guide. The code I read does not use it during install. |
lastModified | date and time | No | When 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. |
preambleContent | rich text | No | Shown on the desktop's preamble page, before installation starts. |
epilogueContent | rich text | No | Shown on the desktop's finish page, after installation. |
widescreenWarningContent | rich text | No | Warning shown on the desktop's widescreen page, with a Copy button. |
aspyrExclusiveWarningContent | rich text | No | Notice shown on the desktop's Aspyr notice page. |
installationWarningContent | rich text | No | Kept 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.
| Key | Type | Required? | Meaning |
|---|---|---|---|
Guid | GUID text | Yes | Identifies the component. Must be unique across all components and options. Letter case does not matter. |
Name | text | Yes | The mod's name, shown in the mod list. Blank names are refused. |
Author | text | No | The mod's author. |
Description | rich text | No | Main description of the mod. |
DescriptionSpoilerFree | rich text | No | Used instead of Description when spoiler-free mode is on. The same pattern applies to Directions, DownloadInstructions, UsageWarning and Screenshots. |
Directions | rich text | No | Installation directions for the player. |
DownloadInstructions | rich text | No | How the player obtains the mod's files. |
UsageWarning | rich text | No | A warning the player should read before using the mod. |
Screenshots | rich text | No | Screenshot text shown with the component. |
Heading | text | No | Section heading used when the guide is exported to Markdown. |
Tier | text | No | Priority. 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. |
Category | text or list | No | Categories for filtering. A single text value is read as a one-item list. |
Language | text or list | No | Languages the mod supports, shown with the component. |
InstallationMethod | text | No | Free text describing how the mod installs, for example Executable Installer. Shown in the summary as "uses ...". It does not change what is installed. |
ExcludedDownloads | kept as written | No | Accepted and saved. I did not find code that acts on it. |
Dependencies | GUID text or list | No | Components (or immediate options) that must be selected. Validation warns when one is not selected. Install refuses the selection. |
Restrictions | GUID text or list | No | Components that cannot be installed together with this one. If one of them is selected, validation reports an error and install refuses. |
InstallBefore | GUID text or list | No | This component installs before the listed ones. Ignored in Markdown guides. |
InstallAfter | GUID text or list | No | This component installs after the listed ones. Ignored in Markdown guides. |
IsSelected | boolean | No | Whether the component is selected by default. A missing value means false. If a non-Markdown file selects nothing, every component is selected on load. |
Instructions | list of steps | No | The steps that install the mod, run in order. See Instructions. |
Options | list of options | No | Choices the player can pick. See Options and choices. |
ResourceRegistry | map | No | Download links and their file details, keyed by URL. See Archive and download fields. |
ModLink, ModLinkFilenames | legacy | No | Older forms of download links. They are moved into ResourceRegistry when the guide loads. |
WidescreenOnly | boolean | No | Marks a widescreen-only component. See Game detection and flags. |
AspyrExclusive | boolean | No | Marks 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:
| Key | Type | Required? | Meaning |
|---|---|---|---|
Guid | GUID | Yes | Identifies the option. A Choose step names options by this value, so give each option a real GUID. |
Name | text | Yes | The option's name, shown to the player. |
Description | text | No | Shown with the option. |
IsSelected | boolean | No | The option's default choice. |
Dependencies | GUID text or list | No | Same meaning as on a component. |
Restrictions | GUID text or list | No | Same meaning as on a component. |
Instructions | list of steps | No | Steps that run only when the option is chosen. |
- An option has no
Author,Category,TierorLanguageof its own. - A
Choosestep in the component'sInstructionslists 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
DependenciesorChooseentry. 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:
| Key | Type | Required? | Meaning |
|---|---|---|---|
Action | text or number | Yes | The action to run. See the list below. An unrecognised name loads as no action and fails validation with "Action cannot be null". |
Source | text or list | Depends on action | Files, folders or archives the action works on. A path with no placeholder is read as relative to <<modDirectory>>. |
Destination | text | Depends on action | A folder, or a new file name for Rename. Must start with a placeholder when it is a path. |
Arguments | text | Depends on action | Extra text whose meaning depends on the action. |
Overwrite | boolean | No | What to do when a target file already exists. Defaults to true, except for Delete, which defaults to false. |
Dependencies | GUID text or list | No | The step runs only when all of these are selected. |
Restrictions | GUID text or list | No | The step is skipped when any of these is selected. |
Guid | text | No | An optional identifier for the step, used by the desktop editor. The install does not depend on it. |
Parent | GUID text | No | Written 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.
| Field | Use |
|---|---|
Source | The archive to unpack, under <<modDirectory>>. Wildcards are allowed. |
Destination | Leave empty. Validation reports an error when it is set. |
Arguments | Not 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.
| Field | Use |
|---|---|
Source | Files to copy. Paths may use a placeholder and wildcards. |
Destination | The folder to copy into. Must start with a placeholder. Validation reports "Destination cannot be found!" when the folder is missing and cannot be created. |
Overwrite | Defaults 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.
| Field | Use |
|---|---|
Source | Files to move. Paths may use a placeholder and wildcards. |
Destination | The folder to move into. Same rules as Copy. |
Overwrite | Defaults 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.
| Field | Use |
|---|---|
Source | The file or files to rename. Paths may use a placeholder and wildcards. |
Destination | The new file name only. It cannot contain a folder, a placeholder, or wildcard characters, and it must be a valid Windows file name. |
Overwrite | Defaults 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.
| Field | Use |
|---|---|
Source | Files to delete. Paths may use a placeholder and wildcards. |
Destination | Leave empty. Validation reports an error when it is set. |
Overwrite | Defaults 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.
| Field | Use |
|---|---|
Source | The extensions to compare, such as ".tga" and ".tpc". When empty, .dds, .tpc and .tga are used. |
Destination | The folder to check. It must already exist. |
Arguments | The 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).
| Field | Use |
|---|---|
Source | The list file. Every Source must exist, and the first one is the file that is read. |
Destination | The folder the listed files are in. It must already exist. |
Arguments | Not 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.
| Field | Use |
|---|---|
Source | Exactly 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. |
Destination | Leave empty, or use <<gameDirectory>>. The patch always runs against the game folder, and validation reports any other value. |
Arguments | Extra 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.
| Field | Use |
|---|---|
Source | The program to start. Every Source is resolved before any program starts. |
Destination | Not used. |
Arguments | The 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.
| Field | Use |
|---|---|
Source | The GUIDs of options, one per entry. A single text value separated by commas or semicolons is also accepted. |
Destination | Leave empty. Validation reports an error when it is set. |
Arguments | Not 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.
| Field | Use |
|---|---|
Source | Must be empty. |
Destination | The folder to create, starting with a placeholder. It cannot be a root folder itself. |
Arguments | Must 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.
| Key | Type | Meaning |
|---|---|---|
ContentHashSHA256 | 64 hexadecimal digits | The expected SHA-256 of the archive. A download that does not match is not accepted. Peer sharing also requires it. |
Magnet | text 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. |
TorrentInfo | base64 text | The torrent's metadata. ModSync checks it against the magnet link's hash. Optional when the magnet link carries a display name. |
Files | map of filename to true, false or null | Which files from a download page to use. false excludes a file. true or null allows it. |
FileSize | number | The file's size in bytes. Legacy entries use 0. |
ContentKey, MetadataHash | text | Identity values for the entry. Legacy entries get a SHA-1 of the URL. |
HandlerMetadata | map | State kept for the download handler. Leave it as {}. |
PrimaryUrl | text | Legacy. Its value becomes the entry's key when the guide loads, and the field is then removed. |
FirstSeen, LastVerified | kept as written | Kept 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:
| Placeholder | Points 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
SourceandDestination, write the placeholder exactly as shown, including capitals. A placeholder in another capitalisation fails. InsideArguments, any capitalisation works. - Separator. The placeholder must be followed by
/or\, or stand alone. Either slash works after it. - No placeholder. A
Sourcewith no placeholder is read as relative to<<modDirectory>>. ADestinationwith no placeholder is refused. - Wildcards.
*(any run of characters) and?(one character) work inSourcefor the file actions. They are refused inDestination, in aRenamefile name, and in aPatcherSource. 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$, andCOMorLPTfollowed 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
Guidor noName. - 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
SourceorDestinationpath 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
InstallBeforeorInstallAfterentry 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
Extractwith 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,DelDuplicateorCleanListwhose Destination folder cannot be found fails with "Destination cannot be found!". Destinationset onExtract,ChooseorDeleteis an error. APatcherDestination other than<<gameDirectory>>is an error.- A
Chooseentry 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
| Stage | What it checks |
|---|---|
| Environment | The game and mod folders exist and can be written to, and the game folder holds no two names that differ only by capitals. |
| Conflicts | Restriction conflicts (errors) and missing dependencies (warnings). |
| Install order | The InstallBefore and InstallAfter rules above. |
| Component validation | Each selected component's archives, Source paths and Destination folders. |
| FOMOD configuration | Archives that use a FOMOD installer have their choices configured. |
| Dry run | Each 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 named4GB Patcher.