How do the different color tokens work for materials

dwarf-fortressmods

What color tokens determine the color of material tiles such as walls, doors, and barrels?

When modding Dwarf Fortress raw files, the format of a color token is fairly simple:

[COLOR:8:7:0]

…where 8 is the foreground color, 7 is the background color, and 0 is the brightness flag. If set to 1, the brightness flag adds eight to the foreground color, if it's not already a bright color (8 through 15). The background color must be a dark color (0 through 7). The color for each number is given in the wiki.

However, there are different types of color tokens: COLOR, DISPLAY_COLOR, BUILD_COLOR, BASIC_COLOR, and TILE_COLOR. Per the wiki, the COLOR token should apply for all, but that doesn't seem to be the case in all circumstances.

I set bronze to [DISPLAY_COLOR:4:2:0], meaning brown foreground and dark green background, expecting that objects such as doors would be mostly bronze-colored with some green, hopefully looking something like a patina. However, when I constructed a door it came out all green. Do metal doors use the background color rather than the foreground color? Testing with another metal I get the same behavior: a door uses the metal's background color. Adding a [BUILD_COLOR:4:2:0] token makes bronze doors brown, but without any green. Doors are described as multi-color in the wiki, but not if made of metal it seems.

I see that wooden barrels and stone doors use the foreground and background colors I specify with DISPLAY_COLOR, as expected, while coffins use the foreground color only. Cages appear to blend the foreground and background colors, as I get slightly different shades of yellow for birch, maple, and pine, which I set to [DISPLAY_COLOR:14:7:0], 14:4:0, and 14:6:0, respectively. Metal bars use the foreground color exclusively. So there's definitely different behavior for different materials and types of buildings.

Best Answer

I changed the colours of 3 materials - a wood, a stone, and a metal - and build objects out of each of them.

  • Wood: [DISPLAY_COLOR:2:5:1] light green, magenta
  • Stone: [DISPLAY_COLOR:3:6:1] light cyan, brown
  • Metal: [DISPLAY_COLOR:4:3:1] light red, cyan
    • [BUILD_COLOR:4:3:0] red, cyan

Lines of objects in different recoloured materials.

Each material uses a different character to display doors - ║ (186) for wood, ≡ (240) for metal, and ┼ (197) for stone and anything else.

With two-colour objects, wood and stone swap the background and foreground colours, and ignore the brightness of the foreground. I think that metal doors do the same (giving the result you described before adding the BUILD_COLOR), but BUILD_COLOR overrides this.

I believe the discrepancies between your description and my results here (blended cages, metal doors showing only one colour, and barrels showing with colours the normal way around) will be due to your choice of tileset.

"Graphical" tilesets (such as Aesomatica's, shown below) often employ tricks so that the pictures show up in the game as nicely as possible. The barrel (in the middle of the bottom row), for example, is actually drawn so that, when the barrel colours are switched, the barrel picture looks like it's using the same foreground colour as other items. If BUILD_COLOR is present, then the colours will look reversed.

Aesomatica's 16x16 picture tileset

Note that the colour behaviour here is identical for all the materials, but only metals, in the default raw files, have the BUILD_COLOR token. The only relevant difference is to do with which tile is chosen to represent the door.