Script Mods
Introduction
This documentation is intended to help you understand how to create script mods for The Ouroboros King.
Script mods are the more complex type of mod to create, as they require programming knowledge. If you want to create text mods, see the Text Mods documentation.
General Information
To create a script mod, you will need to create a class library project in your preferred IDE. Using the .NET Core 2.0 target framework (netstandard2.0) is recommended, as it is the version used by the Unity version The Ouroboros King is built with.
An example project can be found here. Note that the example project only includes a reference to Harmony, so you will need to add the necessary references to the game's libraries yourself.
Getting Started
Create a new class library project: Open your preferred IDE and create a new class library project or open the example project.
Add the necessary references: Add all libraries in the game's
Managed
folder (The Ouroboros King\The Ouroboros King_Data\Managed
(Contents
on Mac)) to your project.Create your mod: Start by creating a new class that inherits from
TOKMod
and override theInit
andLoadContent
method. These methods will be called when the mod is loaded by the game.Build your project: Build your project and copy the DLL file to the
Mods
folder as described in the Home documentation.Run the game: Your mod should be loaded automatically when you run the game. If it is not, check the log file by clicking the Mods button in the main menu.
Entry Points
The game will look for a class that inherits from TOKMod
and calls the Init
and LoadContent
methods. Init
is called when the mod is loaded by the game for the first time. It should be used to set up any necessary data or objects, and return a TOKModInfo
object with information about the mod. Harmony's PatchAll method should be called here if you are using Harmony. LoadContent
is called when the game is loading custom content. Custom content is reloaded whenever the main menu is shown or manually by the user, so this method can be called multiple times. This method should be used to load any custom content, such as pieces or piece overrides.
Documentation
To interact with the game, you can either use the API, or use Harmony to patch the game's code.
API
The API is a set of classes and methods that allow you to interact with the game. The API documentation can be found here.
Harmony
Harmony is a library that allows you to patch the game's code at runtime. The Harmony documentation can be found here.
Logging
To log messages from your mod, you can use the Log
, LogInfo
, LogWarning
, and LogError
methods from the TOKMod
class. These methods will log messages to the modding log, which can be accessed by clicking the Mods button in the main menu.