# This page covers how to make a mod with the PolyModLoader. It is split into 2, since the structure changed with 0.6.0

# Quick Start

# Post-0.6.0

# The file structure of a mod

The basic file structure of a mod looks like this:

exmplemod
|-- 1.0.0
|   |-- main.mod.js
|   `-- version.json
|-- 1.0.1
|   |-- main.mod.js
|   `-- version.json
`-- manifest.json

The 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. 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/<version>/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:

# Pre-0.6.0

# The File Structure Of A Mod

The basic file structure of a mod looks like this:

{16355BFE-B6EB-4274-9BE5-F19994FB3D21}
{16355BFE-B6EB-4274-9BE5-F19994FB3D21}

mod2 is the root directory of a mod (the name can be whatever, mod2 in this case), a link to this file is what should be given to users. The folders underneath the mod's root are versions of the mod.

latest.json is a file that indicates what is the latest version of your mod that supports a certain PolyTrack version, like this:

{
    "0.5.0-beta5": "0.3.0",
    "0.5.0": "0.3.1",
    "0.5.1": "0.3.2"
}

Inside an individual version's root directory, a manifest.json should be preset, looking like this:

{
    "polymod": {
        "name": "Example Mod",
        "id": "examplemod",
        "author": "Example Man",
        "targets": ["0.5.0-beta5"],
        "main": "main.mod.js"
    },
    "dependencies": []
}

"polymod" has to stay as "polymod" and cannot be changed.

  • name: The fancy display name of your mod.
  • id: A unique identifier that is used to identify your mod amongst others and therefore needs to be as unambiguous as possible.
  • author: The author of your mod (you).
  • target: A list of the target versions of PolyTrack for this version of your mod. One of those should match the version in latest.json that this version is pointed to if any.
  • main: The main entry point of your mod, should point to a JavaScript file exporting a variable named polyMod that is an instance of a class extending PolyMod, but more on that later.
  • dependencies: This is where you add your dependencies in the following format:
"dependencies": [
    {
        "id": "examplemod",
        "version": "1.0.0"
    },
    {
        "id": "anothermodid",
        "version": "0.6.4"
    }
]

The versions specified have to be exact matches.

You can also have an image (preferably square) named icon.png for the mod's icon in the mod list provided by PMLCore.

Even more optionally, you can have an HTML file called description.html that gets shown to users when clicking the question mark icon.

# 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/<**put your target polytrack version here**>/PolyModLoader.js";
class YourModClass extends PolyMod {
    
}


export let polyMod = new YourModClass();

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 PolyModLoader import) should be replaced with your mod's target PolyTrack version.
  • The export has to be named polyMod.

# Next Steps: