Element · the document

tile

Every tile document holds exactly one tile. It says how many squares the tile covers and which seed it grows from, and holds everything else: its heights, lines, regions and stack. The tile has no name of its own: its file name is its name.

lib:tiles/water/1x1-water+grass.dtile, the document above, built.
lib:tiles/water/1x1-water+grass.dtile, the document above, from above.

Writing it

dharmatiles version="1.0.0"

tile size="1x1" seed=97 {
    about "Water in the lower half, a meadow bank in the upper."
    line shore wobble="5dmm" { through "wsw" "e" }
    region pool { boundedBy shore; fill "(0.5sq, 0.75sq)" }
    region bank { boundedBy shore; fill "(0.5sq, 0.25sq)" }
    region shoreBand { within "7dmm" of=shore }
    stack {
        base
        dirt {
            pin top="[$waterBedHeight .. $groundHeight + 1dmm]" at=shoreBand   // anywhere from the bed to the land
            pin top="$waterBedHeight" at=pool                                  // later, so it wins in the pool
        }
        water
        scatter at=pool count=2 { rock size="6dmm .. 10dmm" }
        grass at=bank
    }
}

Try it

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

// A range is two values and `..`: each rock draws its own size from it, keyed by the tile's seed.
tile size="1x1" seed=7 {
    stack {
        base
        dirt
        scatter count=5 { rock size="5dmm .. 11dmm" }
    }
}
A tile is squares; a range is two values and ... Each rock draws its own size from it, keyed by the tile's seed: roll the seed for another draw.
The tile this source builds, from above
dharmatiles version="1.0.0"

// A weighted range says which sizes are likelier: `low` favours the small end 4 to 1, so there
// are many small stones and a few big ones.
tile size="1x1" seed=7 {
    stack {
        base
        dirt
        scatter perSquare=14 { rock size="low(3dmm .. 12dmm, 4)" }
    }
}
A weighted range says which sizes are likelier: low(3dmm .. 12dmm, 4) favours the small end four to one.
Nothing buildsthis source gives dt::unit
dharmatiles version="1.0.0"

// A bare number is not a length: the wobble needs a unit, so this tile does not build.
tile size="1x1" seed=4 {
    line stream wobble=5 { through "(0sq, 0.5sq)" "(1sq, 0.5sq)" }
    stack {
        base
        dirt
    }
}
A length carries a unit. Without one the tile does not build, and the message says where and how to mend it: write 5dmm.

Reference

WrittenTakesDefaultWhat it does
size="CxR""1x1"Squares across, then down. A square is 35 mm (DungeonBlocks) or 25.4 mm (OpenLOCK).
seed=a whole number1The root seed. Every element's randomness is keyed from it and the stack, never from the file name, so renaming a tile never changes it; dharmatiles build --seed overrides it.
seams=freekeptA tile's lines may cross its edges only at a seam: a third, a half or two thirds of a square's side, or a tile corner (dt::seam otherwise). seams=free lets this tile's lines cross anywhere.
abouta string—Free text: what the tile is.
leta name and a value—Names this tile adds; override replaces a $ name.
pointa name and a point—Named points.
line—Lines, for divided tiles.
region—Areas bounded by lines.
stack—What the tile is made of. Exactly one.

Notes

The document starts with its header line, and above the tile it may have use lines. Anything else at the top level of a tile document is an error. Positions in the tile count from the north-west corner: across the row, then down the column. The tile is the root region, $tile. The build adds the DungeonBlocks or OpenLOCK base; the document never names it.

The file name is the tile's name everywhere: in the preview, the tile list and the STL (1x1-water+grass.dtile builds 1x1-water+grass-db.stl). To rename a tile, rename its file. Library tiles follow the tile-system naming; your own can be called anything.

Seen from the language

The guide pages that use tile: The tile document, Syntax, Squares, cells and points, Lines, Seams, Units and kinds, Kinds, Seeds, Reading errors, Worked tiles.