forked from mtcontrib/homedecor_modpack
Fixed missing check for ownership/node protection in lights
made lights check for buildable_to instead of just air
This commit is contained in:
parent
1e6ba1103b
commit
cf717ce73f
59
lighting.lua
59
lighting.lua
@ -14,36 +14,49 @@ local dirs1 = { 20, 23, 22, 21 }
|
|||||||
local dirs2 = { 9, 18, 7, 12 }
|
local dirs2 = { 9, 18, 7, 12 }
|
||||||
|
|
||||||
function homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
function homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||||
|
if not homedecor_node_is_owned(pointed_thing.under, placer)
|
||||||
|
and not homedecor_node_is_owned(pointed_thing.above, placer) then
|
||||||
|
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(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 pitch = placer:get_look_pitch()
|
||||||
|
local pname = minetest.env:get_node(under).name
|
||||||
|
local node = minetest.env:get_node(above)
|
||||||
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
|
local wield_name = itemstack:get_name()
|
||||||
|
|
||||||
local above = pointed_thing.above
|
if not minetest.registered_nodes[pname]
|
||||||
local under = pointed_thing.under
|
or not minetest.registered_nodes[pname].on_rightclick then
|
||||||
local pitch = placer:get_look_pitch()
|
|
||||||
local node = minetest.env:get_node(above)
|
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
|
||||||
local wield_name = itemstack:get_name()
|
|
||||||
|
|
||||||
if node.name ~= "air" then return end
|
local iswall = (above.x ~= under.x) or (above.z ~= under.z)
|
||||||
|
local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||||
|
local pos1 = above
|
||||||
|
|
||||||
local iswall = (above.x ~= under.x) or (above.z ~= under.z)
|
if minetest.registered_nodes[pname]["buildable_to"] then
|
||||||
local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
pos1 = under
|
||||||
|
iswall = false
|
||||||
|
end
|
||||||
|
|
||||||
if iswall then
|
if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
|
||||||
minetest.env:add_node(above, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
|
|
||||||
elseif isceiling then
|
if iswall then
|
||||||
minetest.env:add_node(above, {name = wield_name, param2 = 20 }) -- place upside down variant
|
minetest.env:add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
|
||||||
|
elseif isceiling then
|
||||||
|
minetest.env:add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
|
||||||
|
else
|
||||||
|
minetest.env:add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
|
||||||
|
end
|
||||||
|
|
||||||
|
if not homedecor_expect_infinite_stacks then
|
||||||
|
itemstack:take_item()
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
minetest.env:add_node(above, {name = wield_name, param2 = 0 }) -- place right side up
|
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
|
||||||
end
|
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, itemstack)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user