1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2024-12-22 16:10:18 +01:00

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,24 +61,31 @@ for i in ipairs(materials) do
on_place = function(itemstack, placer, pointed_thing)
local pitch = placer:get_look_pitch()
local above = pointed_thing.above
local under = pointed_thing.under
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
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
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_t'})
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
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_t'})
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_b'})
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_b'})
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
})
@ -182,26 +189,31 @@ 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 above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
local node = minetest.env:get_node(above)
if node.name ~= "air" then return end
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_t'})
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_t'})
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_b'})
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_b'})
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
})
@ -304,25 +316,31 @@ for i in ipairs(materials) do
},
on_place = function(itemstack, placer, pointed_thing)
local pitch = placer:get_look_pitch()
local above = pointed_thing.above
local under = pointed_thing.under
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 node = minetest.env:get_node(above)
if node.name ~= "air" then return end
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local node = minetest.env:get_node(above)
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_t'})
if node.name ~= "air" then return end
if above.x ~= under.x or above.z ~= under.z then
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_s', param2 = fdir})
elseif pitch > 0 then
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_t'})
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_b'})
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
else
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_b'})
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer)
end
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
})