diff --git a/tables.lua b/tables.lua index d1bbba4..4105b90 100644 --- a/tables.lua +++ b/tables.lua @@ -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 })