minetest.register_abm

From Minetest Developer Wiki
Jump to: navigation, search

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
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.
  • pos is the position of the node
  • node is the node
  • active_object_count is the amount of objects inside the node
  • active_object_count is the amount of objects inside the node and its neighbours


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

abms begin south/west


Example

minetest.register_abm{
	nodenames = {"group:lava"},
	neighbors = {"group:water"},
	interval = 1,
	chance = 1,
	action = function(pos)
		minetest.set_node(pos, {name = "default:cobblestone"})
	end,
}
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox