Fixed tables' on_place functions to properly check for on_rightclick

on whatever you try to place on, so that the on_rightclick is executed
instead of the table being placed (e.g. it was interfering with doors).
This commit is contained in:
Vanessa Ezekowitz 2013-04-04 22:14:07 -04:00
parent e5c99a3144
commit c2aa7582fd

View File

@ -61,10 +61,14 @@ for i in ipairs(materials) do
on_place = function(itemstack, placer, pointed_thing)
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
@ -79,6 +83,9 @@ for i in ipairs(materials) do
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
})
@ -182,12 +189,14 @@ for i in ipairs(materials) do
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
},
on_place = function(itemstack, placer, pointed_thing)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local pitch = placer:get_look_pitch()
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
@ -202,6 +211,9 @@ for i in ipairs(materials) do
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
})
@ -304,11 +316,14 @@ for i in ipairs(materials) do
},
on_place = function(itemstack, placer, pointed_thing)
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
@ -323,6 +338,9 @@ for i in ipairs(materials) do
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
end
})