Home Report an Issue

Polymod

Atomic modding framework for Haxe

Download with haxelib install polymod

Configuring Polymod

It may be that the default settings are not suitable for your needs. This document will provide all the available options you can configure in your project.

Compiler Configuration

The first type of configuration available for Polymod is the compiler options. You can set these values in your project.xml file using a haxedef tag. You can also modify the appropriate property in PolymodConfig in your code before initializing Polymod, although this is not recommended.

The available options are:

Polymod Parameters

The other type of configuration available for Polymod is the parameters which you may provide to Polymod when you initialize your mods.

Polymod.init({
    /**
     * The directory path on your file system which contains all your mods.
     */
    modRoot: "./mods",

    /**
     * The list of mods to load by ID,
     * where the ID is the directory name of the mod folder relative to `modRoot`.
     */
    dirs: ["mymod"]

    /**
     * (optional) The framework defines which Haxe framework you're using to load assets, which determines what backend to use.
     * Polymod can attempt to determine this automatically, so only use this option
     * if it has trouble, or you need to specify a custom backend.
     */
    framework: CUSTOM,

    /**
     * (optional) Specify any additional configuration paramters needed for your specific Haxe framework.
     */
    frameworkParams: {
        /**
         * Lime/OpenFL only:
         * If you're using custom or non-default asset libraries, then you must provide a key=>value store
         * mapping the name of each asset library to a path prefix in your mod structure.
         * Thus, assets in the `world1` library go in the `world1` folder within your mod folder, etc.
         */
        assetLibraryPaths: [
            "default" => "./preload",
			"world1" => "./world1"
        ]
    },

    /**
     * (optional) A version string which should conform with Semantic Versioning 2.0 standards.
     * This lets you enforce a modding API for your application.
     * Any mod which is not compatible will gracefully fail to load, allowing you to notify the user that the mod needs to be updated.
     * Note that for a mod to be compatible, it must match in both major, minor, AND patch versions.
     * 
     * You should set this to a reasonable value early on, then update it whenever you change how mods interact with your application,
     * including when you change directory structures or modify scripts in a way that introduces breaking changes.
     * 
     * @see https://semver.org/
     */
    apiVersion: "1.0.0",

    /**
     * (optional) A function which takes a `PolymodError` as an argument.
     * 
     * This is called whenever an error occurs within Polymod; if you do not provide a function to call here,
     * any failures will happen silently.
     */
    errorCallback: onError,

    /**
     * (optional) Allows you to ensure a specific version of a mod is loaded by Polymod.
     * 
     * If this array is provided, Polymod will check to see if each mod you attempt to load matches a particular version
     * (as in the mod's own version, not your game/app's modding API version).
     * If any of the mods aren't compatible with the specified version numbers,`errorCallback` will receive a `PARAM_MOD_VERSIONS` error.
     */
    modVersions: ["1.3.0"],

    /**
     * (optional) The parsing rules to use for various data formats.
     * This determines how appending and merging should work for certain file extensions or even specific file names.
     */
    parseRules: getParseRules(),
})

For more information on defining parse rules, see Parse Rules.