code optimization in api.lua
This commit is contained in:
parent
92d7c46484
commit
f1cf661040
31
api.lua
31
api.lua
@ -19,13 +19,8 @@ if config:get_bool("WoolFeeling") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function carpets.register(recipe, def)
|
function carpets.register(recipe, def)
|
||||||
local node = {}
|
|
||||||
|
|
||||||
if def then
|
local node = table.copy(def or {})
|
||||||
for k, v in pairs(def) do
|
|
||||||
node[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(carpet_proto) do
|
for k, v in pairs(carpet_proto) do
|
||||||
node[k] = v
|
node[k] = v
|
||||||
@ -33,29 +28,15 @@ function carpets.register(recipe, def)
|
|||||||
|
|
||||||
local recipe_def = minetest.registered_nodes[recipe]
|
local recipe_def = minetest.registered_nodes[recipe]
|
||||||
|
|
||||||
node.description = node.description or recipe_def.description .. " Carpet"
|
node.description = node.description or recipe_def.description.." Carpet"
|
||||||
node.tiles = node.tiles or recipe_def.tiles
|
node.tiles = table.copy(node.tiles or recipe_def.tiles or {})
|
||||||
|
node.sounds = table.copy(node.sounds or recipe_def.sounds or {})
|
||||||
|
node.groups = table.copy(node.groups or recipe_def.groups or {})
|
||||||
|
|
||||||
if node.tiles[6] then
|
if node.tiles[6] then
|
||||||
-- prefer "front" site for carpet
|
|
||||||
node.tiles = {node.tiles[6]}
|
node.tiles = {node.tiles[6]}
|
||||||
end
|
end
|
||||||
|
node.groups.leafdecay = nil
|
||||||
if not node.sounds then
|
|
||||||
--copy by reference because no change expected
|
|
||||||
node.sounds = recipe_def.sounds
|
|
||||||
end
|
|
||||||
|
|
||||||
if not node.groups then
|
|
||||||
node.groups = {}
|
|
||||||
-- copy by value because of some changes
|
|
||||||
if recipe_def.groups then
|
|
||||||
for k, v in pairs(recipe_def.groups) do
|
|
||||||
node.groups[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
node.groups.leafdecay = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if config:get_bool("FallingCarpet") and node.groups.falling_node == nil then
|
if config:get_bool("FallingCarpet") and node.groups.falling_node == nil then
|
||||||
node.groups.falling_node = 1
|
node.groups.falling_node = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user