forked from nalc/homedecor_modpack
Fix wrong check for ownership on fence placement, respect pointed_thing on_rightclick callback, and support placing fences in buildable_to nodes
This commit is contained in:
parent
049b358c31
commit
53b62463fc
10
fences.lua
10
fences.lua
@ -23,16 +23,6 @@ minetest.register_node("homedecor:fence_brass", {
|
||||
groups = {snappy=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not homedecor_node_is_owned(pointed_thing.under, placer) then
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
minetest.env:add_node(pointed_thing.above, {name = "homedecor:fence_brass", param2 = fdir})
|
||||
itemstack:take_item()
|
||||
placer:set_wielded_item(itemstack)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("homedecor:fence_wrought_iron", {
|
||||
|
@ -417,11 +417,23 @@ function homedecor_register_fence_with_sign(fencename, fencewithsignname)
|
||||
def = copy(def)
|
||||
def_sign = copy(def_sign)
|
||||
fences_with_sign[fencename] = fencewithsignname
|
||||
|
||||
def.on_place = function(itemstack, placer, pointed_thing, ...)
|
||||
local def = minetest.registered_nodes[minetest.env:get_node(pointed_thing.above).name]
|
||||
if (not homedecor_node_is_owned(pointed_thing.under, placer))
|
||||
and def.buildable_to then
|
||||
local node_above = minetest.env:get_node(pointed_thing.above)
|
||||
local node_under = minetest.env:get_node(pointed_thing.under)
|
||||
local def_above = minetest.registered_nodes[node_above.name]
|
||||
local def_under = minetest.registered_nodes[node_under.name]
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
if def_under and def_under.on_rightclick then
|
||||
return def_under.on_rightclick(pointed_thing.under, node_under, placer, itemstack) or itemstack
|
||||
elseif (not homedecor_node_is_owned(pointed_thing.under, placer))
|
||||
and def_under.buildable_to then
|
||||
minetest.env:add_node(pointed_thing.under, {name = fencename, param2 = fdir})
|
||||
itemstack:take_item()
|
||||
placer:set_wielded_item(itemstack)
|
||||
return itemstack
|
||||
elseif (not homedecor_node_is_owned(pointed_thing.above, placer))
|
||||
and def_above.buildable_to then
|
||||
minetest.env:add_node(pointed_thing.above, {name = fencename, param2 = fdir})
|
||||
itemstack:take_item()
|
||||
placer:set_wielded_item(itemstack)
|
||||
|
Loading…
Reference in New Issue
Block a user