Lua Table Formspec

Formspec
Formspec defines a menu. It is represented by a table in Lua. Note, this is not currently implemented and is apparently just a proposal.

Examples

 * Chest:
 * Furnace:
 * Minecraft-like player inventory

Elements

 * Define the size of the menu in inventory slots
 * deprecated:


 * Show an inventory list


 * Show an image
 * Position and size units are inventory slots


 * Show an inventory image of registered item/node
 * Position and size units are inventory slots


 * Use a background. Inventory rectangles are not drawn then.
 * Position and size units are inventory slots
 * Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px


 * Textual password style field; will be sent to server when a button is clicked
 * x and y position the field relative to the top left of the menu
 * w and h are the size of the field
 * fields are a set height, but will be vertically centred on h
 * Position and size units are inventory slots
 * name is the name of the field as returned in fields to on_receive_fields
 * label, if not blank, will be text printed on the top left above the field


 * Textual field; will be sent to server when a button is clicked
 * x and y position the field relative to the top left of the menu
 * w and h are the size of the field
 * fields are a set height, but will be vertically centred on h
 * Position and size units are inventory slots
 * name is the name of the field as returned in fields to on_receive_fields
 * label, if not blank, will be text printed on the top left above the field
 * default is the default value of the field
 * default may contain variable references such as '${text}' which
 * will fill the value from the metadata value 'text'


 * as above but without position/size units
 * special field for creating simple forms, such as sign text input
 * must be used without a {"size"} element
 * a 'Proceed' button will be added automatically


 * same as fields above, but with multi-line input


 * x and y work as per field
 * label is the text on the label
 * Position and size units are inventory slots


 * Textual label drawn verticaly
 * x and y work as per field
 * label is the text on the label
 * Position and size units are inventory slots


 * Clickable button. When clicked, fields will be sent.
 * x, y and name work as per field
 * w and h are the size of the button
 * label is the text on the button
 * Position and size units are inventory slots


 * x, y, w, h, and name work as per button
 * texture name is the filename of an image
 * Position and size units are inventory slots


 * x, y, w, h, and name work as per button
 * texture name is the filename of an image
 * Position and size units are inventory slots
 * noclip true means imagebutton doesn't need to be within specified formsize


 * x, y, w, h, and name work as per button
 * texture name is the filename of an image
 * Position and size units are inventory slots
 * noclip true means imagebutton doesn't need to be within specified formsize
 * drawborder draw button border or not


 * x, y, w, h, and name work as per button
 * texture name is the filename of an image
 * Position and size units are inventory slots
 * noclip true means imagebutton doesn't need to be within specified formsize
 * drawborder draw button border or not
 * pressed is the filename of an image on pressed state


 * x, y, w, h, name and label work as per button
 * item name is the registered name of an item/node,
 * tooltip will be made out of its description
 * Position and size units are inventory slots


 * When clicked, fields will be sent and the form will quit.


 * When clicked, fields will be sent and the form will quit.


 * Scrollable itemlist showing arbitrary text elements
 * x and y position the itemlist relative to the top left of the menu
 * w and h are the size of the itemlist
 * name fieldname sent to server on doubleclick value is current selected element
 * list elements can be a table with color, e.g. {"list element 1", {text="list element 2", color="ff0000"}, "list element 3"}


 * Scrollable itemlist showing arbitrary text elements
 * x and y position the itemlist relative to the top left of the menu
 * w and h are the size of the itemlist
 * name fieldname sent to server on doubleclick value is current selected element
 * list elements can be a table with color, e.g. {"list element 1", {text="list element 2", color="ff0000"}, "list element 3"}
 * draw transparent background


 * show a tabHEADER at specific position (ignores formsize)
 * x and y position the itemlist relative to the top left of the menu
 * name fieldname data is transferred to lua
 * captions specifies name shown on top of tab
 * current_tab index of selected tab
 * transparent (optional) show transparent
 * draw_border (optional) draw border


 * simple colored semitransparent box
 * x and y position the box relative to the top left of the menu
 * w and h are the size of box
 * color in hexadecimal format RRGGBB


 * dropdown field
 * x and y position of dropdown
 * width of dropdown
 * fieldname data is transferred to lua
 * items to be shown in dropdown
 * index of currently selected dropdown item


 * show a checkbox
 * x and y position of checkbox
 * name fieldname data is transferred to lua
 * label to be shown left of checkbox
 * selected (optional) true/false

Inventory location:


 * : Selected node metadata (deprecated: "current_name")
 * : Player to whom the menu is shown
 * : Any player
 * : Any node metadata
 * : A detached inventory