Scarlet is a thin-wrapper library that simplifies the layout of formspec elements.

API / Library

Scarlet (Saner Coordinates and Rational Layouts Expression Translator) is a thin-wrapper library that provides consistent and uniform layout of all elements within Minetest formspecs. Being a purely Lua-based implementation has the advantage that backwards compatibility even with legacy versions of Minetest is assured. No patches and/or upgrades to the engine are required.


Here is a quick summary of the various oddities and inconsistencies (many of which are still undocumented) that I have addressed:

Scarlet has been successfully tested with Minetest 0.4.15, 0.4.17, and 5.0.0. This mod is still in alpha and changes are to be expected. However, I will make every effort to reduce breakage between versions whenever possible.

Usage Instructions

Formspec elements in Minetest 0.4.x and Minetest 5.0 do not conform to any standard units of measurement. In fact, positions and dimensions can vary widely as illustrated in the following table.

A cell unit represents the interval between the left (or top) edge of one inventory slot to the left (or top) edge of a subsequent inventory slot. An image size unit represents the width (or height) of one or more inventory images. A slot unit represents the interval between the left (or top) edge of one inventory slot to the right (or bottom) edge of a subsequent inventory slot.

For simplicity and convenience, Scarlet provides six interchangeable units of measurement: dot, point, slot, cell, image size, and button height. Button heights, of course, only apply to y-axis position and dimension values. And slots pertain solely to dimension values.

For each of the following elements, <w>,<h> is a dimension value and <x>,<y> is a position value. Note that a few elements only accept a <w> dimension value.

Measurements may be expressed as integers or floating points, with the exception of dots which are always integers. Each value may be suffixed by a single letter indicating the unit of measurement. Here are some examples:

Position values are signed, whereas dimension values are unsigned. This permits placement of elements anywhere relative to the form origin and any parent containers.

All units of measurement are independent of pixel density, with the exception of dots which have a 1:1 correspondence to pixels. Hence, if you need pixel-based precision, then you should use dots with the correct translator above. Points will scale to maintain a consistent dot pitch of 72 points per inch, in accordance with the official standard (this assumes that the client's screen_dpi setting is correct).

An interactive GUI-based calculator can be accessed by issuing the /scarlet command (requires "server" privilege).

Ratings and Reviews


Do you recommend this mod?