-
Notifications
You must be signed in to change notification settings - Fork 12
Defining mods
Modot defines a mod as a collection of C# assemblies (.dll
files), XML documents (.xml
files), and resource packs (.pck
files).
These are all optional - meaning it is possible to have a mod with multiple assemblies, XML documents, and resource packs, but it is also possible to have a mod with none of each (though that would essentially do nothing).
When loading mods, Modot does not actually load them all in one go. Instead, it loads each mod's metadata first.
The metadata of a mod contains information about its name, author, and so on, but most importantly, it contains information about dependencies, incompatibilities, and load order. This information is crucial to have, as it lets Modot perform validity checks and load mods in the correct order to prevent conflicts or other issues.
Specifically, a mod's metadata contains the following information:
-
Id
: This is the unique ID of a mod. No two mods can have the same ID. -
Name
: This is the (non-unique) name of a mod. Modot does not actually use this for any purpose, but it exists for use by developers (eg. when displaying loaded mods, or creating mod managers). -
Author
: This is the individual or group who created the mod. Similar to the mod's name, Modot has no use for it, and it exists solely for use by developers. -
Dependencies
: These are the IDs of other mods that the mod depends on. A mod must always be loaded along with its dependencies, if any - usually after them, but not necessarily. -
Incompatible
: These are the IDs of other mods that the mod is incompatible with. A mod must never be loaded along with its incompatibilities, if any. -
After
: These are the IDs of other mods that must be loaded before the mod. They don't necessarily have to be present - but if they are, then the mod must be loaded after them. -
Before
: These are the IDs of other mods that must be loaded after the mod. They don't necessarily have to be present - but if they are, then the mod must be loaded before them.
Any directory with a Mod.xml
file is considered to be a mod directory. It follows from this that for Modot to successfully recognise and load a mod from a directory, it must contain a Mod.xml
file directly inside it.
A sample Mod.xml
file would look something like:
<?xml version="1.0" encoding="UTF-8"?>
<Mod>
<Id>Mod ID</Id>
<Name>Mod name</Name>
<Author>Mod author(s) name</Author>
<Dependencies>
<item>Dependency 1 ID</item>
<item>Dependency 2 ID</item>
<!-- etc -->
</Dependencies>
<Incompatible>
<item>Incompatible 1 ID</item>
<item>Incompatible 2 ID</item>
<!-- etc -->
</Incompatible>
<After>
<item>Load after 1 ID</item>
<item>Load after 2 ID</item>
<!-- etc -->
</After>
<Before>
<item>Load before 1 ID</item>
<item>Load before 2 ID</item>
<!-- etc -->
</Before>
</Mod>
The Id
, Name
, and Author
elements must always be present in the metadata file. Dependencies
, Incompatible
, After
, and Before
are not mandatory, as it is not always the case that a mod has dependencies, incompatibilities, or other load order requirements.
The mod metadata file must also be valid for a mod to be loaded successfully. A valid metadata file has valid XML, contains the Id
, Name
, and Author
elements with relevent data, and does not contain the mod's own ID in the Dependencies
, Incompatible
, After
, or Before
elements.
A mod directory can have an optional Assemblies
sub-directory. Any .dll
files present in this directory will be loaded as C# assemblies when the mod is loaded.
It is important to note that assemblies are lazy-loaded due to the lazy nature of LINQ and IEnumerable<T>
. This means that if a developer chooses to not execute code from mod assemblies, the assemblies will probably never be loaded at all, unless the developer iterates over them at least once.
A mod directory can have an optional Data
sub-directory. Any .xml
files present in this directory will be loaded and then composed into a single XmlNode
when the mod is loaded.
A mod directory can have an optional Resources
sub-directory. Any .pck
files present in this directory will be loaded as resource packs when the mod is loaded.