
function toppings_api.register_topped(base_name, topping)
	local base = minetest.registered_nodes[base_name]
	assert(base, base_name .. " is not registered")

	--copy definition
	local topped = {}
	for k, v in pairs(base)
	do
		topped[k] = v
	end

	--creating texture

	local basetext = {}
	local tiles = topped.tiles
	if #tiles == 1
	then
		basetext.top = tiles[1]
		basetext.bottom = tiles[1]
		basetext.sides = tiles[1]
	elseif #tiles == 3 --we assume that it's already topped
	then
		basetext.top = tiles[1]
		basetext.bottom = tiles[2]
		basetext.sides = tiles[3].name
	end

	topped.tiles =
	{
		basetext.top .. "^" .. topping.top,
		basetext.bottom,
		{
			name = basetext.sides .. "^" .. topping.sides,
			tileable_vertical = false,
		}
	}
	topped.description = topping.description
	--overwriting sounds is optional
	if topping.sounds
	then
		topped.sounds = topping.sounds
	end

	--registering the node

	minetest.register_node(topping.name, topped)
	erosion.register_erosion({topping.name, base_name})
end
