nodes - Uberi/MineTest-API GitHub Wiki
Nodes
Nodes are the bulk data of the world: cubes and other things that take the space of a cube. Huge amounts of them are handled efficiently, but they are quite static.
The definition of a node is stored and can be accessed by name in minetest.registered_nodes[node.name]
See 'registry')); ?>.
Nodes are passed by value between Lua and the engine. They are represented by a table: {name="name", param1=num, param2=num}
param1
and param2
are 8 bit integers. The engine uses them for certain automated functions. If you don't use these functions, you can use them to store arbitrary values.
The functions of param1
and param2
are determined by certain fields in the node definition.
param1
is reserved for the engine when paramtype != "none":
paramtype = "light"
The value stores light with and without sun in it's upper and lower 4 bits.
param2
is reserved for the engine when any of these are used:
liquidtype == "flowing"
The level and some flags of the liquid is stored in param2drawtype == "flowingliquid"
The drawn liquid level is read from param2drawtype == "torchlike"
drawtype == "signlike"
paramtype2 == "wallmounted"
The rotation of the node is stored in param2. You can make this value by using[minetest.dir_to_wallmounted](minetest.dir_to_wallmounted)()
.paramtype2 == "facedir"
The rotation of the node is stored in param2. Furnaces and chests are rotated this way. Can be made by using[minetest.dir_to_facedir](minetest.dir_to_facedir)()
.
Node Metadata
The instance of a node in the world normally only contains the values mentioned in "Nodes". However, it is possible to insert extra data into a node. It is called "node metadata".
Metadata contains two things:
- A key-value store
- An inventory
Some of the values in the key-value store are handled specially:
formspec
Defines a right-click inventory menu. See "Formspec".infotext
Text shown on the screen when the node is pointed at
Example stuff:
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"list[context;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Chest");
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
print([dump](dump)(meta:to_table()))
meta:from_table({
inventory = {
main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "", [5] = "", [6] = "", [7] = "", [8] = "", [9] = "", [10] = "", [11] = "", [12] = "", [13] = "", [14] = "default:cobble", [15] = "", [16] = "", [17] = "", [18] = "", [19] = "", [20] = "default:cobble", [21] = "", [22] = "", [23] = "", [24] = "", [25] = "", [26] = "", [27] = "", [28] = "", [29] = "", [30] = "", [31] = "", [32] = ""}
},
fields = {
formspec = "invsize[8,9;]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
infotext = "Chest"
}
})
Node drawtypes
- normal
- airlike
- liquid
- flowingliquid
- glasslike
- allfaces
- allfaces_optional
- torchlike
- signlike
- plantlike
- fencelike
- raillike
- nodebox -- See below
Node boxes
Node selection boxes are defined using "node boxes"
The "nodebox" node drawtype allows defining visual of nodes consisting of arbitrary number of boxes. It allows defining stuff like stairs. Only the fixed
box type is supported for these.
A nodebox is defined as any of:
{
-- A normal cube; the default in most things
type = "regular"
}
{
-- A fixed box (facedir param2 is used, if applicable)
type = "fixed",
fixed = box OR {box1, box2, ...}
}
{
-- A box like the selection box for torches
-- (wallmounted param2 is used, if applicable)
type = "wallmounted",
wall_top = box,
wall_bottom = box,
wall_side = box
}
A box is defined as {x1, y1, z1, x2, y2, z2}
. A box of a regular node would look like {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
.
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)