atl-build
atl-build takes an ordinary Scrap Mechanic mod folder, with .wasm files where the scripts
would be .lua files, and turns it into a mod the game can load. You write
description.json, the shape and tool databases, the inventory text and everything else as
you would for any mod. Only the scripts change.
It runs on Linux, macOS and Windows. Downloads will be published on GitHub.
atl-build path/to/MyMod -o "<Scrap Mechanic>/Mods/MyMod"Options
Section titled "Options"- Without
-o, the mod goes tobuild/<folder name>next to the mod folder. The output can't be inside the mod folder, and the mod folder can't be inside the output. --checkchecks the mod without writing anything.
The whole mod is checked first, and every problem is reported with its file and line, so a failed build leaves the output alone.
Pointing parts and tools at a class
Section titled "Pointing parts and tools at a class"Give the .wasm file as the script file and the class as usual:
{ "partList": [ { "uuid": "4dec7cdb-0d72-44a2-8732-e1da29a55fae", "renderable": "$CONTENT_DATA/Objects/Renderable/lamp.rend", "hull": { "x": 1, "y": 1, "z": 1, "col": "$CONTENT_DATA/Objects/Collision/lamp.obj" }, "scripted": { "filename": "$CONTENT_DATA/Scripts/lamps.wasm", "classname": "Lamp" } } ]}A tool's "script": { "file": ..., "class": ... } works the same way, and so does any other
filename/classname or file/class pair in the mod's JSON files.
What it changes
Section titled "What it changes"Each .wasm file is packed into a .json next to it with the same name:
Scripts/lamps.wasm becomes Scripts/lamps.json. That file holds the module's
metadata and bytes, so hand-written Lua, such as a custom game's
Game.lua, can load the module with
sm.allthelanguages.register(sm.json.open("$CONTENT_DATA/Scripts/lamps.json")). The .wasm
itself isn't shipped. Every .wasm in the mod is packed, even one the JSON files don't name.
Each class named gets a Lua script next to its module (Scripts/lamps.Lamp.lua), and the
reference is changed to point at it. The class keeps its name, which becomes a Lua global, as
a Lua script's class would. Only the string is replaced, so comments and layout stay as
written.
description.json gets AllTheLanguages added to its dependencies, unless it's already
there.
A bootstrap autoTool (Scripts/atl_bootstrap.lua, in
Tools/Database/ToolSets/atl_bootstrap.toolset) registers every module when the mod loads,
with nothing placed. It's added to Tools/Database/toolsets.tooldb, which is created if the
mod doesn't have one. If registering fails, because AllTheLanguages isn't installed or the mod
is damaged, the error goes to the game's log and players see a popup,
Gui/Layouts/atl_regfail.layout. A "Custom Game" gets neither, because its game script does
the same job.
Every other file is copied as it is. Dot-files and folders (.git, .vscode) and files an OS
leaves behind (Thumbs.db, desktop.ini) are left out. A mod with no .wasm files is copied
unchanged.
Module metadata
Section titled "Module metadata"A .json that already sits next to a .wasm with the same name holds that module's
metadata, in mod.json's format without wasm. Anything it leaves out
is filled in:
| Key | Default |
|---|---|
id |
<description.json localId>/<path without .wasm>, for example 7595def4-.../Scripts/lamps |
name |
description.json's name, plus (<module>) when the mod has several modules |
version |
description.json's version |
language |
read from the module's producers section, which clang writes with -g |
dependencies |
none |
When a module depends on another module in the same mod, the scripts atl-build writes
register the dependency first.
Windows paths
Section titled "Windows paths"The game runs on Windows, so a build on any OS rejects file names Windows can't hold (like
aux.lua) and files whose names differ only by case. A script reference must use the file's
exact case.
Checks
Section titled "Checks"atl-build checks each module's section structure, that it imports only atl functions (no
memory, table or global, so link without --import-memory), and that each named class exists.
It doesn't decode instruction bodies; problems there are reported by the game when the mod
loads.