Quick Start
This page covers how to make a mod with PolyModLoader.
Basic info
PolyModLoader mods are written in JavaScript. If you prefer to use TypeScript, you can also make your mod in TypeScript and compile it to JavaScript.
More on TypeScript on the TypeScript page
Template repositories
If you don't want to set up the file structure yourself, you can use a repository template.
There are repo templates for both JavaScript and TypeScript on both Codeberg and Github.
| GitHub | Codeberg |
|---|---|
| JavaScript | JavaScript |
| TypeScript | TypeScript |
The file structure of a mod
The basic file structure of a mod looks like this:
examplemod
|-- 1.0.0
| |-- main.mod.js
| `-- version.json
|-- 1.0.1
| |-- main.mod.js
| `-- version.json
`-- manifest.jsonThe subfolders are named after the version contained within them. Since 0.6.0, these HAVE to be valid semver versions for it to work properly.
manifest.json is the mod manifest. It looks like this:
{
"name": "Example mod",
"author": "Jerry",
"id": "example mod",
"latest": {
"0.6.0-beta1": "1.0.0",
"0.6.0": "1.0.1"
}
}name: The name of the mod
author: The mod Author(s)
id: The unique mod id
latest: The latest mod version for each game version
The format for latest is "polytrack-version": "mod-version"
version.json contains version-specific data. It looks like this:
{
"targets": ["0.6.0-beta1", "0.6.0"],
"dependencies": [
{
"id": "pmlapi",
"version": "1.0.0"
}
],
"main": "main.mod.js"
}targets: The PolyTrack versions this specific version of the mod supports
dependencies: Other mods this specific version of the mod depends on
- Since 0.6.0, this fully supports semver notation
main: The name of the mod's main js file
Mods can also include an icon.png file as the mod icon that shows up in the mod menu. Icon.png should be square and good quality(preferably 300x300 or higher).
Mods can also include description.html, which shows up in the mod menu when the user clicks the ? on the mod in the mod menu.
Both of these files are version-specific, so they should be included in the version folder
Setting up a basic mod file
Your main mod file (as pointed by the main entry of your manifest.json) would look like this:
import { PolyMod } from "https://cdn.polymodloader.com/cb/PolyTrackMods/PolyModLoader/<target>/PolyTypes.js";
class YourModClass extends PolyMod {
}
export let polyMod = new YourModClass();import { PolyMod } from "https://cdn.polymodloader.com/cb/PolyTrackMods/PolyModLoader/<target>/PolyTypes.js";
class YourModClass extends PolyMod {
}
export let polyMod = new YourModClass();Note the import is PolyTypes.js and NOT PolyModLoader.js
This is the most basic form of a mod, literally doing nothing but showing up in the mod list. A few things to note:
<target>(in the PolyTypes import) should be replaced with your mod's target PolyTrack version.- The export has to be named polyMod.
Next Steps:
- Add some Init Functions to your mod
- Register some Mixins