minetest.get_node_or_nil

From Minetest Developer Wiki
Jump to: navigation, search

Syntax

minetest.get_node_or_nil(pos)

Description

This function does same as minetest.get_node, except that it returns nil if the node is "ignore".
It's implemented there.
You likely want to use this together with vmanip to detect whether a mapblock is loaded, see below.

Example

local function my_get_node(pos)
	-- Get the node if it's loaded
	local node = minetest.get_node_or_nil(pos)
	if not node then
		-- Load the map at pos and try again
		minetest.get_voxel_manip():read_from_map(pos, pos)
		node = minetest.get_node(pos)
	end
	-- If node.name is "ignore" here, the map probably isn't generated at pos.
	return node
end
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox