forked from mtcontrib/plantlife_modpack
Early exit from abstract_ferns.grow_giant_tree_fern
(very) small performance increase
This commit is contained in:
parent
27430814a0
commit
99dd2db18a
@ -11,8 +11,14 @@
|
|||||||
-- lot of code, lot to load
|
-- lot of code, lot to load
|
||||||
|
|
||||||
abstract_ferns.grow_giant_tree_fern = function(pos)
|
abstract_ferns.grow_giant_tree_fern = function(pos)
|
||||||
local size = math.random(12,16) -- min of range must be >= 4
|
|
||||||
local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
|
local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
if minetest.get_node(pos_01).name ~= "air"
|
||||||
|
and minetest.get_node(pos_01).name ~= "ferns:sapling_giant_tree_fern"
|
||||||
|
and minetest.get_node(pos_01).name ~= "default:junglegrass" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local size = math.random(12,16) -- min of range must be >= 4
|
||||||
|
|
||||||
local leave_a_1 = {x = pos.x + 1, y = pos.y + size - 1, z = pos.z }
|
local leave_a_1 = {x = pos.x + 1, y = pos.y + size - 1, z = pos.z }
|
||||||
local leave_a_2 = {x = pos.x + 2, y = pos.y + size , z = pos.z }
|
local leave_a_2 = {x = pos.x + 2, y = pos.y + size , z = pos.z }
|
||||||
@ -34,92 +40,86 @@ abstract_ferns.grow_giant_tree_fern = function(pos)
|
|||||||
local leave_d_3 = {x = pos.x , y = pos.y + size - 1, z = pos.z - 3}
|
local leave_d_3 = {x = pos.x , y = pos.y + size - 1, z = pos.z - 3}
|
||||||
local leave_d_4 = {x = pos.x , y = pos.y + size - 2, z = pos.z - 4}
|
local leave_d_4 = {x = pos.x , y = pos.y + size - 2, z = pos.z - 4}
|
||||||
|
|
||||||
if minetest.get_node(pos_01).name == "air" -- instead of check_air = true,
|
for i = 1, size-3 do
|
||||||
or minetest.get_node(pos_01).name == "ferns:sapling_giant_tree_fern"
|
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"})
|
||||||
or minetest.get_node(pos_01).name == "default:junglegrass" then
|
|
||||||
|
|
||||||
for i = 1, size-3 do
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"})
|
|
||||||
end
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"})
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"})
|
|
||||||
|
|
||||||
-- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result
|
|
||||||
|
|
||||||
if minetest.get_node(leave_a_1).name == "air" then
|
|
||||||
minetest.set_node(leave_a_1, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_a_2).name == "air" then
|
|
||||||
minetest.set_node(leave_a_2, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_a_3).name == "air" then
|
|
||||||
minetest.set_node(leave_a_3, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_a_4).name == "air" then
|
|
||||||
minetest.set_node(leave_a_4, {name="ferns:tree_fern_leave_big_end", param2=3})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_b_1).name == "air" then
|
|
||||||
minetest.set_node(leave_b_1, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_b_2).name == "air" then
|
|
||||||
minetest.set_node(leave_b_2, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_b_3).name == "air" then
|
|
||||||
minetest.set_node(leave_b_3, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_b_4).name == "air" then
|
|
||||||
minetest.set_node(leave_b_4, {name="ferns:tree_fern_leave_big_end", param2=1})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_c_1).name == "air" then
|
|
||||||
minetest.set_node(leave_c_1, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_c_2).name == "air" then
|
|
||||||
minetest.set_node(leave_c_2, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_c_3).name == "air" then
|
|
||||||
minetest.set_node(leave_c_3, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_c_4).name == "air" then
|
|
||||||
minetest.set_node(leave_c_4, {name="ferns:tree_fern_leave_big_end", param2=2})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_d_1).name == "air" then
|
|
||||||
minetest.set_node(leave_d_1, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_d_2).name == "air" then
|
|
||||||
minetest.set_node(leave_d_2, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_d_3).name == "air" then
|
|
||||||
minetest.set_node(leave_d_3, {name="ferns:tree_fern_leave_big"})
|
|
||||||
if minetest.get_node(leave_d_4).name == "air" then
|
|
||||||
minetest.set_node(leave_d_4, {name="ferns:tree_fern_leave_big_end", param2=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- bug fixes # 2 - doesn't really work, so disabled for now
|
|
||||||
--[[if minetest.get_node(leave_a_4).name == "ferns:tree_fern_leave_big_end"
|
|
||||||
and minetest.get_node(leave_a_3).name == "ferns:fern_trunk_big" then
|
|
||||||
minetest.set_node(leave_a_4, {name="air"})
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_b_4).name == "ferns:tree_fern_leave_big_end"
|
|
||||||
and minetest.get_node(leave_b_3).name == "ferns:fern_trunk_big" then
|
|
||||||
minetest.set_node(leave_b_4, {name="air"})
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_c_4).name == "ferns:tree_fern_leave_big_end"
|
|
||||||
and minetest.get_node(leave_c_3).name == "ferns:fern_trunk_big" then
|
|
||||||
minetest.set_node(leave_c_4, {name="air"})
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest.get_node(leave_d_4).name == "ferns:tree_fern_leave_big_end"
|
|
||||||
and minetest.get_node(leave_d_3).name == "ferns:fern_trunk_big" then
|
|
||||||
minetest.set_node(leave_d_4, {name="air"})
|
|
||||||
end]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"})
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"})
|
||||||
|
|
||||||
|
-- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result
|
||||||
|
|
||||||
|
if minetest.get_node(leave_a_1).name == "air" then
|
||||||
|
minetest.set_node(leave_a_1, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_a_2).name == "air" then
|
||||||
|
minetest.set_node(leave_a_2, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_a_3).name == "air" then
|
||||||
|
minetest.set_node(leave_a_3, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_a_4).name == "air" then
|
||||||
|
minetest.set_node(leave_a_4, {name="ferns:tree_fern_leave_big_end", param2=3})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_b_1).name == "air" then
|
||||||
|
minetest.set_node(leave_b_1, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_b_2).name == "air" then
|
||||||
|
minetest.set_node(leave_b_2, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_b_3).name == "air" then
|
||||||
|
minetest.set_node(leave_b_3, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_b_4).name == "air" then
|
||||||
|
minetest.set_node(leave_b_4, {name="ferns:tree_fern_leave_big_end", param2=1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_c_1).name == "air" then
|
||||||
|
minetest.set_node(leave_c_1, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_c_2).name == "air" then
|
||||||
|
minetest.set_node(leave_c_2, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_c_3).name == "air" then
|
||||||
|
minetest.set_node(leave_c_3, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_c_4).name == "air" then
|
||||||
|
minetest.set_node(leave_c_4, {name="ferns:tree_fern_leave_big_end", param2=2})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_d_1).name == "air" then
|
||||||
|
minetest.set_node(leave_d_1, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_d_2).name == "air" then
|
||||||
|
minetest.set_node(leave_d_2, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_d_3).name == "air" then
|
||||||
|
minetest.set_node(leave_d_3, {name="ferns:tree_fern_leave_big"})
|
||||||
|
if minetest.get_node(leave_d_4).name == "air" then
|
||||||
|
minetest.set_node(leave_d_4, {name="ferns:tree_fern_leave_big_end", param2=0})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- bug fixes # 2 - doesn't really work, so disabled for now
|
||||||
|
--[[if minetest.get_node(leave_a_4).name == "ferns:tree_fern_leave_big_end"
|
||||||
|
and minetest.get_node(leave_a_3).name == "ferns:fern_trunk_big" then
|
||||||
|
minetest.set_node(leave_a_4, {name="air"})
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_b_4).name == "ferns:tree_fern_leave_big_end"
|
||||||
|
and minetest.get_node(leave_b_3).name == "ferns:fern_trunk_big" then
|
||||||
|
minetest.set_node(leave_b_4, {name="air"})
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_c_4).name == "ferns:tree_fern_leave_big_end"
|
||||||
|
and minetest.get_node(leave_c_3).name == "ferns:fern_trunk_big" then
|
||||||
|
minetest.set_node(leave_c_4, {name="air"})
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_node(leave_d_4).name == "ferns:tree_fern_leave_big_end"
|
||||||
|
and minetest.get_node(leave_d_3).name == "ferns:fern_trunk_big" then
|
||||||
|
minetest.set_node(leave_d_4, {name="air"})
|
||||||
|
end]]
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user