forked from mtcontrib/homedecor_modpack
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:
parent
e5c99a3144
commit
c2aa7582fd
108
tables.lua
108
tables.lua
@ -61,24 +61,31 @@ for i in ipairs(materials) do
|
|||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
local pitch = placer:get_look_pitch()
|
local node = minetest.env:get_node(pointed_thing.under)
|
||||||
local above = pointed_thing.above
|
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
|
||||||
local under = pointed_thing.under
|
|
||||||
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 above = pointed_thing.above
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
local under = pointed_thing.under
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_s', param2 = fdir})
|
local pitch = placer:get_look_pitch()
|
||||||
elseif pitch > 0 then
|
local node = minetest.env:get_node(above)
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_square_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_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
|
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
|
end
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -182,26 +189,31 @@ for i in ipairs(materials) do
|
|||||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
|
fixed = { -0.5, -0.5, -0.5, 0.5, -0.4375, 0.5 },
|
||||||
},
|
},
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
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 above = pointed_thing.above
|
local under = pointed_thing.under
|
||||||
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
|
if above.x ~= under.x or above.z ~= under.z then
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_s', param2 = fdir})
|
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_s', param2 = fdir})
|
||||||
elseif pitch > 0 then
|
elseif pitch > 0 then
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_small_round_t'})
|
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
|
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
|
end
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -304,25 +316,31 @@ for i in ipairs(materials) do
|
|||||||
},
|
},
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
local pitch = placer:get_look_pitch()
|
local node = minetest.env:get_node(pointed_thing.under)
|
||||||
local above = pointed_thing.above
|
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
|
||||||
local under = pointed_thing.under
|
|
||||||
|
|
||||||
local node = minetest.env:get_node(above)
|
local above = pointed_thing.above
|
||||||
if node.name ~= "air" then return end
|
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
|
if node.name ~= "air" then return end
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_s', param2 = fdir})
|
if above.x ~= under.x or above.z ~= under.z then
|
||||||
elseif pitch > 0 then
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
minetest.env:add_node(above, {name = 'homedecor:'..m..'_table_large_t'})
|
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
|
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
|
end
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user