In this chapter you will learn how to manipulate a node’s metadata.
- What is Node Metadata?
- Getting a Metadata Object
- Reading Metadata
- Setting Metadata
- Lua Tables
- Your Turn
Metadata is data about data. So Node Metadata is data about a node.
You may use metadata to store:
- an node’s inventory (such as in a chest).
- progress on crafting (such as in a furnace).
- who owns the node (such as in a locked chest).
The node’s type, light levels,
and orientation are not stored in the metadata, but rather are part
of the data itself.
Metadata is stored in a key value relationship.
Once you have a position of a node, you can do this:
Here are all the get functions you can use, as of writing:
In order to do booleans, you should use
Setting meta data works pretty much exactly the same way.
Here are all the set functions you can use, as of writing:
You can convert to and from lua tables using
The Minetest Engine reads the field
infotext in order to make text
appear on mouse-over. This is used by furnaces to show progress and signs
to show their text.
- Make a block which disappears after it has been punched 5 times.
(use on_punch in the node def and minetest.set_node)