Fix sapling growth generating error messages

The reason was that the code tried to spawn mcl_core:apple, which is not a node
This commit is contained in:
Wuzzy 2017-02-17 03:46:12 +01:00
parent 2efa5e6c96
commit 241a392fc1

@ -164,14 +164,6 @@ minetest.register_on_dignode(function(pos, node)
end end
end) end)
local function apple_leave()
if math.random(0, 10) == 3 then
return {name = "mcl_core:apple"}
else
return {name = "mcl_core:leaves"}
end
end
local function air_leave() local function air_leave()
if math.random(0, 50) == 3 then if math.random(0, 50) == 3 then
return {name = "air"} return {name = "air"}
@ -223,40 +215,24 @@ function mcl_core.generate_tree(pos, trunk, leaves, typearbre)
if dx == 0 and dz == 0 and dy==3 then if dx == 0 and dz == 0 and dy==3 then
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.add_node(pos, node) minetest.add_node(pos, node)
if rarity == 1 then minetest.add_node(pos, air_leave())
minetest.add_node(pos, apple_leave())
else
minetest.add_node(pos, air_leave())
end
end end
elseif dx == 0 and dz == 0 and dy==4 then elseif dx == 0 and dz == 0 and dy==4 then
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.add_node(pos, node) minetest.add_node(pos, node)
if rarity == 1 then minetest.add_node(pos, air_leave())
minetest.add_node(pos, apple_leave())
else
minetest.add_node(pos, air_leave())
end
end end
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
if minetest.get_node(pos).name == "air" then if minetest.get_node(pos).name == "air" then
minetest.add_node(pos, node) minetest.add_node(pos, node)
if rarity == 1 then minetest.add_node(pos, air_leave())
minetest.add_node(pos, apple_leave())
else
minetest.add_node(pos, air_leave())
end
end end
else else
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.add_node(pos, node) minetest.add_node(pos, node)
if rarity == 1 then
minetest.add_node(pos, apple_leave())
else
minetest.add_node(pos, air_leave()) minetest.add_node(pos, air_leave())
end end
end
end end
end end
pos.x = pos.x-dx pos.x = pos.x-dx