forked from nalc/homedecor_modpack
avoid duplicating get_nodedef_field() function
(both doors/gates and desk need it) moved to init.lua and into homedecor.* namespace.
This commit is contained in:
parent
f8efeee4d7
commit
ba3abaa6a6
|
@ -412,13 +412,6 @@ minetest.register_alias("homedecor:fence_picket_gate_white_closed", "homedecor:g
|
|||
|
||||
----- helper functions
|
||||
|
||||
local function get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
function homedecor.place_door(itemstack, placer, pointed_thing, name, forceright)
|
||||
|
||||
local pointed = pointed_thing.under
|
||||
|
@ -459,8 +452,8 @@ function homedecor.place_door(itemstack, placer, pointed_thing, name, forceright
|
|||
return
|
||||
end
|
||||
|
||||
if not get_nodedef_field(node_bottom.name, "buildable_to")
|
||||
or not get_nodedef_field(node_top.name, "buildable_to") then
|
||||
if not homedecor.get_nodedef_field(node_bottom.name, "buildable_to")
|
||||
or not homedecor.get_nodedef_field(node_top.name, "buildable_to") then
|
||||
minetest.chat_send_player( placer:get_player_name(), S('Not enough space above that spot to place a door!') )
|
||||
else
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
|
|
|
@ -54,6 +54,14 @@ function homedecor.table_copy(t)
|
|||
return nt
|
||||
end
|
||||
|
||||
--
|
||||
|
||||
function homedecor.get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
-- load various other components
|
||||
|
||||
|
|
|
@ -489,13 +489,6 @@ minetest.register_node('homedecor:utility_table_legs', {
|
|||
},
|
||||
})
|
||||
|
||||
local function get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
|
||||
local fdir_to_right = {
|
||||
{ 1, 0 },
|
||||
{ 0, -1 },
|
||||
|
@ -546,8 +539,8 @@ minetest.register_node("homedecor:desk", {
|
|||
local tnode = minetest.get_node(pos)
|
||||
local tnode2 = minetest.get_node(pos2)
|
||||
|
||||
if get_nodedef_field(tnode.name, "buildable_to")
|
||||
and get_nodedef_field(tnode2.name, "buildable_to")
|
||||
if homedecor.get_nodedef_field(tnode.name, "buildable_to")
|
||||
and homedecor.get_nodedef_field(tnode2.name, "buildable_to")
|
||||
and not minetest.is_protected(pos, placer:get_player_name())
|
||||
and not minetest.is_protected(pos2, placer:get_player_name()) then
|
||||
minetest.add_node(pos, { name = "homedecor:desk", param2 = fdir })
|
||||
|
|
Loading…
Reference in New Issue
Block a user