The result

dharmatiles version="1.0.0"
use "parts/grass" lawn
tile size="1x2" seed=7 {
// From the middle of the south edge to the middle of the north edge,
// 9 design millimetres wide, wandering up to 3 off its points.
line trail width="9dmm" wobble="3dmm" { through south "(0.65sq, 1sq)" north }
// Everything beside the path: one fill point on each side of it.
region verge { boundedBy trail; fill "(0.15sq, 1sq)"; fill "(0.85sq, 1sq)" }
stack {
base
dirt // the whole tile, at the ground height
dirt at=trail top="$bottom + [0.4dmm .. 0.8dmm]" clods=none // the path: a second dirt along it, a little proud and smooth
scatter at=verge count=5 {
rock size="4dmm .. 10dmm" shape=rounded buried="30%" // shape: or angular, flat
}
lawn at=verge cover="85%"
}
}
lawn is a part: it comes from library/parts/grass.dtile by a use line.Say it plainly
Parts files hold definitions. A use line names the file and the definitions it brings in, so a reader always knows where a name came from.
A definition is called like an element. Its params are set as properties, and a place such as at= passes through to the elements inside it.
The rules
A use line names the file and the definitions it brings in
Parts files hold definitions that tiles bring in by name. A use line names the file and the definitions it brings in, so a reader knows where every name came from:
use "parts/grass" lawn long-grass
A bare path such as "parts/grass" is the bundled library, and "lib:parts/grass" says so explicitly. "./mine" or "../shared/x" is a file in the author's project. Anything else is an error.
A define is a stack with params, called like an element
A define has param lines and one stack. It is called like an element; its params are set as properties, and a place (at=) passes through to the elements inside it. A definition can call another. A definition whose stack is one thing is itself a thing, so it can be placed with at= or scattered: scatter count=2 { oak }. Definitions that call each other in a loop are an error (dt::loop).
dharmatiles version="1.0.0"
// library/parts/grass.dtile
define lawn {
param length "3.5dmm .. 6.5dmm" // blade length along the ground
param height "1.5dmm .. 2dmm" // how tall a blade stands over the ground
param clearings 0 // patches of bare earth per square
param cover "100%" // share of the ground grassed over
stack {
grass length=length height=height clearings=clearings cover=cover
}
}
// Long, tall blades: the species of 2x2-grass-tree.
define long-grass {
stack {
lawn length="5dmm .. 9dmm" height="2dmm .. 3dmm"
}
}
A param takes its kind from its default or the control it fills
A param takes its kind from its default or, with none, from the control it fills: param length "3.5dmm .. 6.5dmm" is a length, param clearings 0 a plain number, and a caller that writes length=5 gets dt::unit asking for 5dmm. A param without a default must be given by the caller. A tile has no params. Expert controls live in parts files:
Expert controls live in parts files
dharmatiles version="1.0.0"
// library/parts/trees.dtile
define oak {
stack {
tree top="$bottom + 59dmm" {
trunk height="18dmm"
crown width="44dmm" clumps=60 shape=wide
branch split="34deg" eagerness=0.6 target=0.25 balance=0.8 exponent=3 minRadius="0.9dmm"
}
}
}
A call's top= is the tree's. A tile places one oak as oak at="(1sq, 1sq)" top="$bottom + 60dmm", or several as scatter count=2 { oak }.
Errors this page explains
Next
Next: overhang and the gate, what every build is checked against before it is written.