Node - Uberi/MineTest-API GitHub Wiki

Node

Description

Nodes (Blocks)

Syntax

{
	[all fields allowed in item definitions](Item.html),

	drawtype = "normal", -- See "Node drawtypes"
	visual_scale = 1.0,
	tiles = {tile definition 1, def2, def3, def4, def5, def6},
	^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
	^ List can be shortened to needed length
	special_tiles = {tile definition 1, Tile definition 2},
	^ Special textures of node; used rarely (old field name: special_materials)
	^ List can be shortened to needed length
	alpha = 255,
	post_effect_color = {a=0, r=0, g=0, b=0}, -- If player is inside node
	paramtype = "none", -- See "Nodes"
	paramtype2 = "none", -- See "Nodes"
	is_ground_content = false, -- Currently not used for anything
	sunlight_propagates = false, -- If true, sunlight will go infinitely through this
	walkable = true, -- If true, objects collide with node
	pointable = true, -- If true, can be pointed at
	diggable = true, -- If false, can never be dug
	climbable = false, -- If true, can be climbed on (ladder)
	buildable_to = false, -- If true, placed nodes can replace this node
	drop = "", -- alternatively drop = { max_items = ..., items = { ... } }
	liquidtype = "none", -- "none"/"source"/"flowing"
	liquid_alternative_flowing = "", -- Flowing version of source liquid
	liquid_alternative_source = "", -- Source version of flowing liquid
	liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
	light_source = 0, -- Amount of light emitted by node
	damage_per_second = 0, -- If player is inside node, this damage is caused
	node_box = {type="regular"}, -- See "Node boxes"
	selection_box = {type="regular"}, -- See "Node boxes"
	legacy_facedir_simple = false, -- Support maps made in and before January 2012
	legacy_wallmounted = false, -- Support maps made in and before January 2012
	sounds = {
		footstep = [SimpleSoundSpec](SimpleSoundSpec.html),
		dig = [SimpleSoundSpec](SimpleSoundSpec.html), -- "__group" = group-based sound (default)
		dug = [SimpleSoundSpec](SimpleSoundSpec.html),
	},

	on_construct = func(pos),
	^ Node constructor; always called after adding node
	^ Can set up metadata and stuff like that
	^ default: nil
	on_destruct = func(pos),
	^ Node destructor; always called before removing node
	^ default: nil
	after_destruct = func(pos, oldnode),
	^ Node destructor; always called after removing node
	^ default: nil

	after_place_node = func(pos, placer),
	^ Called after constructing node when node was placed using
	minetest.item_place_node / minetest.env:place_node
	^ default: nil
	after_dig_node = func(pos, oldnode, oldmetadata, digger),
	^ oldmetadata is in table format
	^ Called after destructing node when node was dug using
	minetest.node_dig / minetest.env:dig_node
	^ default: nil
	can_dig = function(pos,player)
	^ returns true if node can be dug, or false if not
	^ default: nil

	on_punch = func(pos, node, puncher),
	^ default: minetest.node_punch
	^ By default: does nothing
	on_dig = func(pos, node, digger),
	^ default: minetest.node_dig
	^ By default: checks privileges, wears out tool and removes node

	on_timer = function(pos,elapsed),
	^ default: nil
	^ called by NodeTimers, see EnvRef and [NodeTimerRef](NodeTimerRef.html)
	^ elapsed is the total time passed since the timer was started
	^ return true to run the timer for another cycle with the same timeout value

	on_receive_fields = func(pos, formname, fields, sender),
	^ fields = {name1 = value1, name2 = value2, ...}
	^ Called when an UI form (eg. sign text input) returns data
	^ default: nil

	allow_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
	^ Called when a player wants to move items inside the inventory
	^ Return value: number of items allowed to move

	allow_metadata_inventory_put = func(pos, listname, index, stack, player),
	^ Called when a player wants to put something into the inventory
	^ Return value: number of items allowed to put
	^ Return value: -1: Allow and don't modify item count in inventory

	allow_metadata_inventory_take = func(pos, listname, index, stack, player),
	^ Called when a player wants to take something out of the inventory
	^ Return value: number of items allowed to take
	^ Return value: -1: Allow and don't modify item count in inventory

	on_metadata_inventory_move = func(pos, from_list, from_index, to_list, to_index, count, player),
	on_metadata_inventory_put = func(pos, listname, index, stack, player),
	on_metadata_inventory_take = func(pos, listname, index, stack, player),
	^ Called after the actual action has happened, according to what was allowed.
	^ No return value

	on_blast = func(pos, intensity),
	^ intensity: 1.0 = mid range of regular TNT
	^ If defined, called when an explosion touches the node, instead of removing the node
}
⚠️ **GitHub.com Fallback** ⚠️