Mod API (For other MOD developers) - Electric131/Sandustry-CustomMapLoader GitHub Wiki

This page is up to date as of v4.1.3

Mod API

Note: This page is for people intending to create a mod that uses data from the custom map loader

If you're looking for scripting your own map, check out map scripting.

This mod exposes all of it's information through the globalThis property CML. Map data can be found under CML.mapData and contains all information for the currently loaded map.

Note that on the main menu, every map's mapData is exposed through CML.maps.

Map Data

The CML.mapData object contains internal data about the currently loaded map.

This data includes the following:

valid

A simple true/false to show if this map had an error while loading or not.

error

Only present if valid is false, and specifies what went wrong when loading the map.

name

The name of the map.. Note this is the name as defined in the modinfo.json and the map author can change it at any time.

id

The id of the map.. Note this is the modID as defined in the modinfo.json file and will not change once the map is uploaded.

version

The loaded version of the map, following semantic versioning (defined by the modinfo file)

author

The author of the map (mod), as defined in the modinfo.json. Note there are no restrictions regarding syntax or what characters are allowed

width

The width of the map images (The game requires square images, so will end up being the same as height)

height

The height of the map images (The game requires square images, so will end up being the same as width)

meta

This object contains all of the metadata for the loaded map. This can be edited in realtime through the console to visualize changes.