From fbed3bfab265390f5b45f5a3c55b2e14d5d3bb9e Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 20 Jul 2014 10:29:12 -0400 Subject: [PATCH] use modern protection function in tabletop nodes --- homedecor/tables.lua | 87 ++------------------------------------------ 1 file changed, 3 insertions(+), 84 deletions(-) diff --git a/homedecor/tables.lua b/homedecor/tables.lua index 0f73e7d1..351ab4f9 100644 --- a/homedecor/tables.lua +++ b/homedecor/tables.lua @@ -51,35 +51,7 @@ for i in ipairs(materials) do type = "fixed", fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 }, }, - - on_place = function(itemstack, placer, pointed_thing) - - local node = minetest.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.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.add_node(above, {name = 'homedecor:'..m..'_table_small_square_s', param2 = fdir}) - elseif pitch > 0 then - minetest.add_node(above, {name = 'homedecor:'..m..'_table_small_square_t'}) - else - minetest.add_node(above, {name = 'homedecor:'..m..'_table_small_square_b'}) - end - if not homedecor.expect_infinite_stacks then - itemstack:take_item() - return itemstack - end - else - minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer) - end - end + on_place = minetest.rotate_node }) minetest.register_node('homedecor:'..m..'_table_small_square_t', { @@ -181,33 +153,7 @@ for i in ipairs(materials) do type = "fixed", fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 }, }, - on_place = function(itemstack, placer, pointed_thing) - local node = minetest.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.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.add_node(above, {name = 'homedecor:'..m..'_table_small_round_s', param2 = fdir}) - elseif pitch > 0 then - minetest.add_node(above, {name = 'homedecor:'..m..'_table_small_round_t'}) - else - minetest.add_node(above, {name = 'homedecor:'..m..'_table_small_round_b'}) - end - if not homedecor.expect_infinite_stacks then - itemstack:take_item() - return itemstack - end - else - minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer) - end - end + on_place = minetest.rotate_node }) minetest.register_node('homedecor:'..m..'_table_small_round_t', { @@ -307,34 +253,7 @@ for i in ipairs(materials) do type = "fixed", fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 }, }, - on_place = function(itemstack, placer, pointed_thing) - - local node = minetest.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.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.add_node(above, {name = 'homedecor:'..m..'_table_large_s', param2 = fdir}) - elseif pitch > 0 then - minetest.add_node(above, {name = 'homedecor:'..m..'_table_large_t'}) - else - minetest.add_node(above, {name = 'homedecor:'..m..'_table_large_b'}) - end - if not homedecor.expect_infinite_stacks then - itemstack:take_item() - return itemstack - end - else - minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer) - end - end + on_place = minetest.rotate_node }) minetest.register_node('homedecor:'..m..'_table_large_t', {