The tile language · guide

The tile document

A tile is one short text file: a header line, then one tile with a size and a stack of the things to build.

The result

The tile this source builds, from above
dharmatiles version="1.0.0"

// library/tests/ground/1x1-flat.dtile
tile size="1x1" {
    about "Flat ground at the edge height (3.4 mm) on one square: the first tile built end to end."
    stack {
        base
        dirt top="$dirtEdgeHeight" clods=none   // flat, at the edge height (3.4 mm)
    }
}
The smallest tile in the library, built: one square of flat ground at the edge height, on its connector base.

Say it plainly

A tile document is a .dtile file. It says which version of the language it is written in, then describes one tile: how big it is, and a stack of elements, listed bottom up, that the program builds in the order you wrote them.

Everything else in the guide is something you can write inside that stack or beside it: lines and regions to divide the tile, lengths and ranges to size things, names to reuse a number, parts to reuse a whole stack.

The rules

A tile document is one tile after a header

A tile document is one .dtile file holding exactly one tile node, after a header line. The tile has a size and a seed, and a body with (its file name is its name: tile takes none):

  • about: optional free text, one string;
  • let and override: optional names this tile adds or replaces (names);
  • point, line and region: places, for tiles divided into areas;
  • stack: exactly one, listing the elements and definitions that make the tile.

Between the header and the tile, a file may have use lines that bring in definitions from parts files. Parts files hold let nodes with a body. Two library files use two more top-level nodes: printer (the printer profile) and defaults (the edge contract). Anything else at the top level is an error.

A document of any kind (a tile, a parts file, a printer profile, a palette) starts with one line that says which version of the language it is written in:

dharmatiles version="1.0.0"

It is the first node of the file, once; it takes version= and nothing else. By hand the major number is enough: dharmatiles version=1. A version with a second dot or a + is quoted, since KDL reads a bare 1.10 as the number 1.1. Only the major part matters to reading: it is the document's format, and this program reads format 1. The editor writes the full version of the program that wrote the file, as the library's files do ("1.0.0"); re-saving a document leaves the line as it is.

A document with no header is format 0, the language before this one, and this program does not read it: the decoder refuses it with dt::format-0, wherever the tile is shown (the CLI, the preview, the editor); its help names release 1.0.0 (tag v1.0.0), which carries a file to format 1 with dharmatiles migrate. A document of a newer format than the program reads is refused with dt::format-newer. A header out of place, repeated or malformed has its own error (dt::header, dt::header-first, dt::header-twice, dt::header-version).

dharmatiles --version and the editor's About box (in the view's ⋯ menu) give the program's own version and the formats it reads. The program's version is drawn from git: X.Y.Z at the release tag vX.Y.Z; X.Y.Z+N.gHASH on main, N commits past it; X.Y.Z+branch.N.gHASH on another branch; and .dirty added when the engine's files have uncommitted changes. A build record carries it.

The smallest tile is a size and a stack

The smallest tile in the library is the one above:

Its stack starts with base, the connector; a stack with no base line has no base, and prints flat on the bed from zero. dharmatiles build lib:tests/ground/1x1-flat.dtile builds it for DungeonBlocks, the default system.

The guide uses a few words in one way

element
Anything a document can write: the document's own (tile, line, region, stack, …) and the built-in terrain (dirt, grass, rock, tree, wall, cliff, …), plus scatter. Each has a page in the elements reference.
control
A setting of an element, written as a property (height="40dmm") or as a child line (height "40dmm").
group
A control that holds only sub-controls, written as properties on its own line: leaf length="4.5dmm" width="3dmm".
thing
One solid object: a rock, a tree, or a let whose body is one thing written bare (an oak).
definition
A let with a body (let lawn { … }): a named thing or layer that a tile calls like an element.

Errors this page explains

Next

Next: syntax, the shape of a document.