forked from mtcontrib/plantlife_modpack
[ferns] Optimize math.random call function
This commit is contained in:
parent
d7b543f5d7
commit
4dcf14ce1f
@ -11,6 +11,8 @@ local S = minetest.get_translator("ferns")
|
|||||||
|
|
||||||
assert(abstract_ferns.config.enable_treefern == true)
|
assert(abstract_ferns.config.enable_treefern == true)
|
||||||
|
|
||||||
|
local random = math.random
|
||||||
|
|
||||||
abstract_ferns.grow_tree_fern = function(pos)
|
abstract_ferns.grow_tree_fern = function(pos)
|
||||||
|
|
||||||
local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z}
|
local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
@ -20,12 +22,12 @@ abstract_ferns.grow_tree_fern = function(pos)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local size = math.random(1, 4) + math.random(1, 4)
|
local size = random(1, 4) + random(1, 4)
|
||||||
if (size > 5) then
|
if (size > 5) then
|
||||||
size = 10 - size
|
size = 10 - size
|
||||||
end
|
end
|
||||||
size = size + 1
|
size = size + 1
|
||||||
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
|
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[random(1, 2)]
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
local brk = false
|
local brk = false
|
||||||
|
Loading…
Reference in New Issue
Block a user