Add oldnode parameter to minetest.register_on_placenode callback
authorPerttu Ahola <celeron55@gmail.com>
Mon, 23 Jul 2012 17:44:56 +0000 (20:44 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 23 Jul 2012 17:44:56 +0000 (20:44 +0300)
builtin/item.lua
doc/lua_api.txt

index 08b8d1c58aa16ccd10348e7ca9fd67052d0e0ecc..e19fd559a21fd1a299ea1946708cb590409a0cbe 100644 (file)
@@ -152,7 +152,8 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
 
                minetest.log("action", placer:get_player_name() .. " places node "
                        .. def.name .. " at " .. minetest.pos_to_string(place_to))
-
+               
+               local oldnode = minetest.env:get_node(place_to)
                local newnode = {name = def.name, param1 = 0, param2 = 0}
 
                -- Calculate direction for wall mounted stuff like torches and signs
@@ -188,7 +189,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
                -- Run script hook (deprecated)
                local _, callback
                for _, callback in ipairs(minetest.registered_on_placenodes) do
-                       callback(place_to, newnode, placer)
+                       callback(place_to, newnode, placer, oldnode)
                end
 
                itemstack:take_item()
index d0af5b4db28d356e5a67bae48189fce2b14e36e1..176745a2d75207893c657e908ee6e6b7acf66d2c 100644 (file)
@@ -774,11 +774,11 @@ minetest.register_craft(recipe)
 Global callback registration functions: (Call these only at load time)
 minetest.register_globalstep(func(dtime))
 ^ Called every server step, usually interval of 0.05s
-minetest.register_on_placenode(func(pos, newnode, placer))
+minetest.register_on_placenode(func(pos, newnode, placer, oldnode))
 ^ Called when a node has been placed
 ^ Deprecated: Use on_construct or after_place_node in node definition instead
 minetest.register_on_dignode(func(pos, oldnode, digger))
-^ Called when a node has been dug. digger can be nil.
+^ Called when a node has been dug.
 ^ Deprecated: Use on_destruct or after_dig_node in node definition instead
 minetest.register_on_punchnode(func(pos, node, puncher))
 ^ Called when a node is punched