formspec - Uberi/MineTest-API GitHub Wiki

Minetest API

Formspec

Formspec defines a menu. Currently not much else than inventories are supported. It is a string, with a somewhat strange format.

Spaces and newlines can be inserted between the blocks, as is used in the examples.

Examples

Chest:

    invsize[8,9;]
    list[context;main;0,0;8,4;]
    list[current_player;main;0,5;8,4;]

Furnace:

    invsize[8,9;]
    list[context;fuel;2,3;1,1;]
    list[context;src;2,1;1,1;]
    list[context;dst;5,1;2,2;]
    list[current_player;main;0,5;8,4;]

Minecraft-like player inventory

    invsize[8,7.5;]
    image[1,0.6;1,2;player.png]
    list[current_player;main;0,3.5;8,4;]
    list[current_player;craft;3,0;3,3;]
    list[current_player;craftpreview;7,1;1,1;]

Elements

Position and size units are inventory slots

size

Define the size of the menu in inventory slots

size[W,H]

list

Show an inventory list

list[inventory_location;list_name;X,Y;W,H;]
list[inventory_location;list_name;X,Y;W,H;starting_item_index]

image

Show an image, Position and size units are inventory slots

image[X,Y;W,H;texture_name]

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

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. Note: no extra text or more than a single variable is supported ATM.

field[X,Y;W,H;name;label;default]

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

field[name;label;default]

label

x and y work as per field, label is the text on the label

label[X,Y;label]

button

Clickable button. When clicked, fields will be sent.

x and y work as per field, w and h are the size of the button, label is the text on the label

button[X,Y;W,H;name;label]

image_button

x, y, w and h work as per button, image is the filename of an image

image_button[X,Y;W,H;texture name;name;label]

button_exit

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

button_exit[X,Y;W,H;name;label]

image_button_exit

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

image_button_exit[X,Y;W,H;texture name;name;label]

Inventory location

  • context Selected node metadata (deprecated: "current_name")
  • current_player Player to whom the menu is shown
  • player:name Any player
  • nodemeta:X,Y,Z Any node metadata
  • detached:name A detached inventory

Afterword

Minetest Links

Lua Links

We're Social

Chat with us

There are developers, modders, themers, server admins and players on IRC at freenode on the channel #minetest (chatlogs)

Webchat