minetest.register_on_placenode

From Minetest Developer Wiki
Jump to: navigation, search

Syntax

minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing))

Description

Called when a node has been placed.

Return a true value to indicate modification of itemstack (if any) has been handled by the callback. Otherwise (return nothing, false, or nil) the caller will remove one item from itemstack. Note that it is not generally possible for one on_placenode callback to know what values were returned by others, or by a node's after_place_node callback (one should thus be careful to avoid double-removal of items).

Example

minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
    if oldnode ~= nil then
        print("Node " .. oldnode.name .. " at " ..  minetest.pos_to_string(pos) .. " replaced with " .. newnode.name .. "  by " .. placer:get_player_name())
    else
        print("Node " .. newnode.name .. " at " ..  minetest.pos_to_string(pos) .. " placed by " .. placer:get_player_name())
    end
end)
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox