Plugin System

## Plugin File Format

```
Plugin Directory
 + enabled
 + cml.config
 --Any other files/folders--

```

**Plugin Directory**: The name of the directory will be interpreted as the name of your plugin.

**enabled**: An empty file that (if it exists) makes your plugin enabled by default.

**cml.config**: This plaintext file is used to let CML know how and when to run your plugin. See the *Config File* heading for more information.

**Any other files/folders**: CML will disregard *all* files besides those mentioned above.

## Config File `cml.config`

Lines that do not contain a `:` are considered to be arguments to pass during execution. See below for more info.

Lines that contain a `:` are considered to be properties. See below for more info.

**Arguments**

Exceptions:

`ishook` - For plugins that replace a section of code (Shorthand for `ishook:true`)

`autorun` - For plugins that launch on startup (E.g. backup manager)

`ishandler` - Handles mods prior to being applied (Shorthand for `ishandler:true`)

Replaced at runtime:

`dir` or `directory` - Gets replaced by the plugin's working directory

`"dir"` or `"directory"` - Gets replaced by the plugin's working directory (with surrounding quotes)

`sm_version` - Gets replaced by the version of SM that the user is using, as determined by hashing the EXE file.

**Properties**

`executable` - Relative path to the executable file (if applicable).

`fxml` - Relative path to the FXML file (if applicable).

`execution` - Gives the method of execution. See Execution for more.

`ishook` - `TRUE`/`FALSE` property to set whether this plugin is a hook. [Default: `FALSE`]

`ishandler` - `TRUE`/`FALSE`. property to set whether this plugin is a handler. [Default: `FALSE`]

* When `ishandler` is `TRUE`, the arguments are effectively appended with `mod_directory out_file` - the input and output files, respectively.
* If the handler wishes to ignore the file given, it may write a file to `out_file`. If it is a directory, then CML uses this directory instead of the original mod's directory.

`argument` or `arguments` - Adds the section after the colon to the list of arguments.

`info` - URL to the plugin's info page. If not supplied, the button will be disabled.

`help` - URL to the plugin's help page. If not supplied, the button will be disabled.

`iconUrl` - URL to the plugin's image.

`name` - The display name of the plugin.

`author` - The author(s) to display on the plugin screen.

`description` - A description of the plugin. Use `\n` instead of newline characters.

**Execution**

The `execution` property has some special properties.

Special properties

If an `executable` exists:

* `.jar` files automatically use `java -jar`  unless the `execution` value is set.
* The end result is `execution "executable" arg1 arg2 arg3 etc`.

If an `fxml` exists:

* Execution has no effect.

If no `executable` or `fxml` exists:

* The end result is `execution arg1 arg2 arg3 etc`.

Special keywords

`{$plugindirectory}` - Replaced by the plugin's working directory at runtime.

Example

Inside of a plugin named "Test Plugin," `"{$plugindirectory}/Run.bat"` will run the command: `"C:\Program Files (x86)\Construct\API\plugins\Test Plugin\Run.bat"`.