Skip to content

Commit

Permalink
Pass pointed_thing to after_place_node
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Jan 7, 2014
1 parent 9551f65 commit c46574f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion builtin/item.lua
Expand Up @@ -272,7 +272,13 @@ function minetest.item_place_node(itemstack, placer, pointed_thing, param2)
if def.after_place_node then
-- Copy place_to because callback can modify it
local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
if def.after_place_node(place_to_copy, placer, itemstack) then
local pointed_thing_copy = {
type = pointed_thing.type,
under = pointed_thing.under,
above = pointed_thing.above

This comment has been minimized.

Copy link
@Ekdohibs

Ekdohibs Jan 11, 2014

Member

You should copy under and above to, because mods could modify it.

}
if def.after_place_node(place_to_copy, placer, itemstack,
pointed_thing_copy) then
take_item = false
end
end
Expand Down
2 changes: 1 addition & 1 deletion doc/lua_api.txt
Expand Up @@ -2188,7 +2188,7 @@ Node definition (register_node)
^ Node destructor; always called after removing node
^ default: nil

after_place_node = func(pos, placer, itemstack),
after_place_node = func(pos, placer, itemstack, pointed_thing),
^ Called after constructing node when node was placed using
minetest.item_place_node / minetest.place_node
^ If return true no item is taken from itemstack
Expand Down

0 comments on commit c46574f

Please sign in to comment.