Element · the document

stack

The list of what a tile is made of: surfaces, things, runs, scatters and definitions, one per line. The stack is built in the order it is listed: each entry stands on what is listed above it.

  1. dirt { pin … at=shoreBand; pin … at=pool }
  2. scatter at=pool count=2 { rock size="6dmm .. 10dmm" }
  3. water
  4. grass at=bank
The home page's pond, built one stack line at a time. The dirt covers the whole tile, pinned down to the water's bed in the pool; each later line stands on what is there: the rocks stand on the pool's bed, the water fills round them and rings each with chop, and the grass keeps to the bank. The tile's base line is left out of the pictures. From docs/elements/demo/stack.dtile.

Writing it

stack {
    base
    dirt top="$dirtEdgeHeight" { scatter perSquare=40 { pebble } }
    cliff top="$dirtEdgeHeight + 35dmm" at=crag
    scatter at="foot(cliff)" perSquare=55 reach="4dmm" { stone }
    grass                    // listed last: it grows round the cliff and the stones
}

Try it

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

// The stack is built in the order it is written: the grass is listed after the rocks, so it
// grows round them.  Move the scatter below the grass and see the difference.
tile size="1x1" seed=9 {
    stack {
        base
        dirt
        scatter count=4 { rock size="6dmm .. 10dmm" }
        grass
    }
}
The stack is built in the order it is written: the grass comes after the rocks, so it grows round them. Move the scatter line below grass and look again.
The tile this source builds, from above
dharmatiles version="1.0.0"

// A stack of surfaces and what stands on them: dirt, rocks in the pool, water filling over what
// is under it, then grass on the bank.
tile size="1x1" seed=97 {
    line shore wobble="5dmm" { through "(0sq, 2sq/3)" "(1sq, 0.5sq)" }
    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 {
        dirt { pin top="[$waterBedHeight .. $groundHeight + 1dmm]" at=shoreBand; pin top="$waterBedHeight" at=pool }
        scatter at=pool count=2 { rock size="6dmm .. 10dmm" }
        water
        grass at=bank
    }
}
Dirt, rocks in the pool, water filling over what is under it, then grass on the bank. Each line stands on what the lines above it made.

Reference

Every entry in a stack takes these, whatever it is:

WrittenTakesDefaultWhat it does
seed=a whole number—Pins this entry's randomness while the tile seed changes everything else.
id=a name—Names the entry among same-named siblings, for edits and diagnostics.
weight=a number1Only on a child of a scatter: its share of the mix.
place wordsat= and side=. at= takes a place by name or "(across, down)" with units, an edge or edge path, or foot(cliff); each element page lists the kinds of place it takes (a point, a line, a region, a foot) and refuses the rest with dt::type.
top=a height or a range—On a body (dirt, water, cliff, flagstones, planks): the band it fills. On a tree: its height. Heights are lengths above zero ("$groundHeight + 2dmm"); see let.
a namea name—After a body's element, dirt hillDirt: its name in messages.

Notes

A stack may start with base, and a tile is written bottom up: the base first, the land in order, things, grass and water where they are listed, each over what is listed above it. Water usually goes after the rocks it should ring and before the grass that should see its shore. The pins of a body go in its block: pin top=… at=….

The build plans the stack by what each element reads and writes: surfaces first (a floor is laid with them, on the land they made), then the ground is lifted, then solids, and surfaces that grow round solids after them. A stack that asks for something nothing makes is refused with an error at the entry. The preview lists the stack under the tile's name, each entry linked to its page here.

Seen from the language

The guide pages that use stack: The tile document, The stack, Worked tiles.