do not copy all attributes by default from template, sound, tiles and name base only

This commit is contained in:
Alexander Weber 2017-03-02 21:18:14 +01:00
parent 613c56e91b
commit 12552ce92f

30
api.lua

@ -10,6 +10,12 @@ local carpet_proto = {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5} fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
},
groups = {
snappy = 2,
flammable = 3,
oddly_breakable_by_hand = 3,
choppy = 2
} }
} }
@ -19,24 +25,26 @@ if config:get_bool("WoolFeeling") then
end end
function carpets.register(recipe, def) function carpets.register(recipe, def)
local node = table.copy(carpet_proto)
local node = table.copy(def or {}) if def then
for k,v in pairs(def) do
for k, v in pairs(carpet_proto) do node.k = v
node[k] = v end
else
def = {}
end end
local recipe_def = minetest.registered_nodes[recipe] local recipe_def = minetest.registered_nodes[recipe]
node.description = def.description or recipe_def.description.." Carpet"
node.description = node.description or recipe_def.description.." Carpet" node.tiles = table.copy(def.tiles or recipe_def.tiles or {})
node.tiles = table.copy(node.tiles or recipe_def.tiles or {}) node.sounds = table.copy(def.sounds or recipe_def.sounds or {})
node.sounds = table.copy(node.sounds or recipe_def.sounds or {}) if def.groups then
node.groups = table.copy(node.groups or recipe_def.groups or {}) node.groups = table.copy(def.groups)
end
if node.tiles[6] then if node.tiles[6] then
node.tiles = {node.tiles[6]} node.tiles = {node.tiles[6]}
end end
node.groups.leafdecay = nil
node.base_material = recipe node.base_material = recipe
node.shape_type = "carpet" node.shape_type = "carpet"