correct node definition referencing

This commit is contained in:
Tim 2014-12-30 15:25:43 +01:00
parent 97d73f7358
commit b4777f0394

View file

@ -102,18 +102,24 @@ minetest.register_node("bones:bones", {
}) })
local function may_replace(pos, player) local function may_replace(pos, player)
local nodename = minetest.get_node(pos).name local node_name = minetest.get_node(pos).name
local node_definition = minetest.registered_nodes[node_name]
-- if the node is unknown, we let the protection mod decide
-- unknown decoration would often be removed
-- while unknown building materials in use would usually be left
if node_definition then
-- allow replacing air and liquids -- allow replacing air and liquids
if nodename == "air" or minetest.registered_nodes[nodename].liquidtype ~= "none" then if node_name == "air" or node_definition.liquidtype ~= "none" then
return true return true
end end
-- don't replace filled chests and other nodes that don't allow it -- don't replace filled chests and other nodes that don't allow it
if minetest.registered_nodes[nodename].can_dig and local can_dig_func = node_definition.can_dig
not minetest.registered_nodes[nodename].can_dig(pos, player) then if can_dig_func and not can_dig_func(pos, player) then
return false return false
end end
end
-- only replace nodes that are not protected -- only replace nodes that are not protected
return not minetest.is_protected(pos, player:get_player_name()) return not minetest.is_protected(pos, player:get_player_name())