The tile language · guide

Kinds

Lengths, angles and plain numbers are checked apart, before anything is built.

The result

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 with no unit builds nothing: the program says what to write, 5dmm or 5mm.

Say it plainly

A control wants a kind of value, and a formula has the kind its parts give it. A length plus a length is a length; a length times a plain number is a length; a length plus a plain number is refused.

Because nothing is guessed, a mistake of kind is found at the line it is written on, with what to write instead.

The rules

Lengths, angles and plain numbers are checked apart

Lengths, angles and plain numbers are checked apart, before anything is built. A control wants a kind, and a formula has the kind its parts give it:

WrittenKindWhy
$bottom + 2layerlengthlength + length
1 - $d * $dplain$d is a fraction
$bottom + 30dmm * (1 - $d * $d)lengthlength + length × plain
$groundHeight + 20%errora length plus a plain fraction; write $groundHeight + 20% * 10dmm
$groundHeight + $xerrorsquares counted are plain; write $groundHeight + 4dmm * $x
2dmm * 3dmmerrorno area exists in this language
size=5errora size is a length: dt::unit says to write 5dmm or 5mm
sin(360 * $x)errorsin takes an angle: write sin(360deg * $x)
$region + 1errora region is not a number

A mismatch is dt::type, a number missing its unit dt::unit; both point at the value and say what to write. A let holds whatever its formula is, so let reach "3dmm" is a length wherever it is read and let n 3 a plain number. A param takes its kind from the control it fills (parts).

A thing and a layer are kinds too, and a thing fits where a layer is wanted

The kinds are length, angle, plain number, region, point, and two more: thing and layer (things and layers). A thing makes one solid from its controls and a seed and reads nothing; a layer reads the scene so far and changes it. A stack of entries is a layer, a part that holds several entries is a layer, and a tile is the outermost one.

One rule says whether a value of one kind fits where another is wanted, and every place that checks a name, a param, an entry or a scatter's child asks it: a kind fits itself; a thing fits where a layer is wanted, because placing a thing (rock at=bank) makes it a layer, and that is the only way from a thing to a layer; a layer never fits where a thing is wanted, because nothing makes a layer into a thing; and a number fits neither, nor either a number.

WhereWantsA thingA layer
a stack entry, a param ground kind=layera layerfits (placed, it is a layer)fits
a scatter's child, a param leaf kind=thinga thingfitserror: dirt is a layer, and a scatter wants a thing
a length, an angle, a plain numbera numbererrorerror

A mistake of kind is said one way wherever it is: `dirt` is a layer, and `stand piece` wants a thing, with what to write instead. A part is a thing only when its body is one thing written bare with no place word on it; let corner-rock with rock at="(0.1sq, 0.1sq)" as its body is a layer, because the rock is placed, and so is any part written with a stack.

The editor shows a length as written and as printed

The editor's property sheet shows a length as you wrote it, with its unit (7 dmm), and never changes one unit into another on its own. Hover a unit for what it is, in the program's own words (dmm: design millimetre, 1/35 of a square; 1 mm on DungeonBlocks, 0.73 mm on OpenLOCK). Beside the written value, quieter, it shows what the length prints on the current build target, the system and printer in the title bar: 7 dmm · prints 5.08 mm on OpenLOCK, 3.5–6.5 dmm · prints 2.54–4.72 mm for a range. The printed size shows only where it differs from the number written: never for mm, never for dmm on DungeonBlocks, for every dmm length on OpenLOCK, and always for sq, in and layer. A formula ($groundHeight + 4dmm) shows the printed size it works out to, the $ heights read from the tile as a build reads them. The program works every printed size out, with the same reader and evaluator as a build; the page does no unit arithmetic.

Typing is literal: what you type into a value is written exactly, so 7dmm edited to 7mm is 7mm. A printed number of a plain number or range is typed too: the program writes it back in the value's own unit, so the intent is kept (typing 5 against 7dmm on OpenLOCK writes 6.89dmm; on DungeonBlocks, 5dmm). A printed size reads to 0.01 mm, and the value is written with the fewest decimals that print exactly the size you typed to 0.01 mm. Each end of a range is typed separately and the other end is kept as written. A formula, or a value with odds written on it (low(3dmm .. 6dmm, 2)), only shows its printed size: edit it as written.

Errors this page explains

  • dt::type Kinds do not agree: a length mixed with a plain number, or a place of the wrong kind The rule

Next

Next: names, for reusing a number or a height.