minetest.register_abm
From Minetest Developer Wiki
(Redirected from ABM)
Syntax
minetest.register_abm(abm_defintion_table)
Description
The Active Block Modifier consists of a function that is executed at a specific interval for single nodes.
abm_defintion_table is a table which can contain following fields:
index | description |
---|---|
label | a name used by profiling to show how much time the ABM is using. |
nodenames | a list of the nodenames that should execute the function. "group:groupname" is also possible. |
neighbors | a list of nodenames. At least one of these nodes has to be near node that executes the function (can be omitted). "group:groupname" is also possible. |
interval | the interval in seconds that specifies when the function is executed. |
chance | the inverted chance for each node to execute the function. |
catch_up | if this is set to false, the time when the node was unloaded is ignored thus if chance is 1 and interval is 1, disabling this does nothing. if omitted, it is set to true |
action | the function that is executed. The parameters are (pos, node, active_object_count, active_object_count_wider) The object counts are useful for preventing overcrowding of spawned entities.
|
abms only work in active blocks,
there's the active_block_range setting telling how far blocks are active,
and abm_interval sets the Length of time between ABM execution cycles
Example
minetest.register_abm{ label = "lava cooling", nodenames = {"group:lava"}, neighbors = {"group:water"}, interval = 1, chance = 1, action = function(pos) minetest.set_node(pos, {name = "default:cobblestone"}) end, }