Writing it
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
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
}
}
define long-grass { // a definition can call another
stack { lawn length="5dmm .. 9dmm" height="2dmm .. 3dmm" }
}
A tile then writes use "parts/grass" lawn and lawn cover="80%" in its stack.
Reference
| Written | Takes | Default | What it does |
|---|---|---|---|
define NAME | a name | โ | What callers write. Required. |
param NAME | a default, or none | โ | A control callers may set. Its kind is its default's: param length "3.5dmm .. 6.5dmm" is a length, param clearings 0 a count, and a caller that writes length=5 is asked for 5dmm (dt::unit). With no default, the caller must give it, and its kind is the control it fills. |
stack | โ | What it makes. Exactly one. |
Notes
A place given to the call (at=) pass through to the elements inside, and a call's top= is the height of the tree inside it (oak top="$bottom + 40dmm"). Expert controls, such as a tree's branch knobs, are allowed only in parts files. Definitions that call each other in a loop are an error (dt::loop). A tile has no params. A part has no tile of its own, so a point it writes ("(50%, 0.5sq)") is worked out at each place it is called, and a $ name it reads comes from its caller: check refuses a call whose context lacks one.
Seen from the language
The guide pages that use define: The tile document, Parts.
