# Making your own ct.js modules: directory structure and manifest

Ct.js is moddable, and the process of making new modules is pretty easy! Modules, or catmods, can put new code into ct.js framework, hack on built-in events and procedures, add new project settings and editable fields for game assets.

Any module is a directory with a following structure, placed at ct.js/data/ct.libs:

mycatmod
  |
  |  (Core files)
  |-- index.js
  |-- module.json (required)
  |
  |  (Docs shown in the expanding panel on the right)
  |-- README.md
  |-- docs
      \-- (any number of .md docs)
  |
  |-- CHANGELOG.md
  |-- LICENSE (plain text, strongly recommended)
  |
  |-- includes
  |   \-- (files to be copied to a resulting game)
  |
  \-- injects
      \-- (injections go here)

(more about injections here)

  • module.json allows your module to be discoverable by ct.IDE, and contains basic info, list of authors and description of module settings.

  • index.js usually represents the main code of your module, and is bundled with all the remaining code of compiled game. A rule of thumb is to pack all your dependencies in one file. If your dependency is an another ct module, you can list this module as such in module.json. (See below for examples.) This file supports templating.

  • README.md is a markdown file with general info, examples, special notes, etc. If present, it makes the module's header clickable in the panel with all the modules' docs.

  • CHANGELOG.md should contain a history of changes, if any.

# Structure of module.json

module.json is the only required file for your modules. Its minimal version has the following format:

{
    "main": {
        "name": "Module's name",
        "tagline": "A short description of a module",
        "version": "1.0.0",
        "authors": [{
            "name": "Cosmo Myzrail Gorynych",
            "mail": "admin@nersta.ru"
        }, {
            ...
        }]
    }
}

# Listing dependencies new in v1.3

Currently, catmods may express their dependency in other module with fields dependencies and optionalDependencies inside module.json. It allows ct.IDE to warn users about missing (disabled) modules. Please write info about getting custom modules in the "readme" section.









 
 



{
    "main": {
        "name": "An example module json with dependencies",
        "tagline": "Add dependencies to your modules!",
        "version": "1.0.0",
        "authors": [
            ...
        ]
    },
    "dependencies": ["tween"],
    "optionalDependencies": ["place"]
}

# Specifying a category new in v1.4

Since v1.4, modules can specify one or two categories in module.json so that they can be filtered on the project's settings page. Categories are written in an array under the main.categories key, and can be one of these strings:

  • customization;
  • desktop — modules for desktop builds;
  • fx;
  • inputs — modules that provide new input methods for the Actions system;
  • integrations;
  • media;
  • misc;
  • mobile;
  • motionPlanning;
  • networking;
  • tweaks;
  • utilities;

The first category is also used to create an icon in the bottom-right corner of a module's card:

An example from ct.flow module:










 
 
 



{
    "main": {
        "name": "Flow control and timing",
        "tagline": "Add high-level methods for asynchronous events, e.g. gate, cumulative delay, retriggerable delay.",
        "version": "0.0.0",
        "authors": [{
            "name": "Cosmo Myzrail Gorynych",
            "mail": "admin@nersta.ru"
        }],
        "categories": [
            "utilities"
        ]
    }
}

# Writing a mod

Depending on your needs, you will probably need to:

Follow the links to find the examples and references on further implementation.