minetest.register_lbm
Jump to navigation
Jump to search
Syntax
minetest.register_lbm(lbm_defintion_table)
Description
The Loading Block Modifier consists of a function that is executed when the server loads nodes that match a passed filter.
The LBM registered with the callback will only take effect if register_lbm gets called while the mod is loading.
lbm_defintion_table
is a table which can contain following fields:
index | description |
---|---|
name
|
an unique name for the LBM. It must be in "modname:something" notation. The name is used to distinguish the LBM from the others, thus changing the name resets the introducement time for the LBM. |
nodenames
|
a list of the nodenames that should execute the function. "group:groupname" is also possible, as well as names of non-registered nodes.
|
action
|
the function that is executed. The parameters are (pos, node)
|
Use cases
Originally, LBMs were written for legacy replacement jobs like when a mod defines a new node or to remove nodes from a removed mod for the world. This is still the main use case for LBMs.
Example
A cleanup LBM useful to execute after removal of the fire mod in order to clean up the world from the now unknown nodes:
minetest.register_lbm({
name = "modname:remove_fire",
nodenames = {"fire:basic_flame", "fire:permanent_flame"},
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "air:air"})
end,
})