Browse Source

[ferns] Optimize math.random call function

master
sys4 2 weeks ago
parent
commit
4dcf14ce1f
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      ferns/treefern.lua

+ 4
- 2
ferns/treefern.lua View File

@@ -11,6 +11,8 @@ local S = minetest.get_translator("ferns")

assert(abstract_ferns.config.enable_treefern == true)

local random = math.random

abstract_ferns.grow_tree_fern = function(pos)

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
end

local size = math.random(1, 4) + math.random(1, 4)
local size = random(1, 4) + random(1, 4)
if (size > 5) then
size = 10 - size
end
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 brk = false


Loading…
Cancel
Save