[vines] Optimize math.random call function

This commit is contained in:
Sys Quatre 2020-07-23 21:23:51 +02:00
parent 10ff005066
commit 1f52bbea19
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni

Vedi File

@ -18,6 +18,8 @@ minetest.register_craftitem("vines:vines", {
-- FUNCTIONS
local random = math.random
local function dig_down(pos, node, digger)
if digger == nil then return end
@ -80,7 +82,7 @@ vines.register_vine = function( name, defs, biome )
local timer = minetest.get_node_timer(pos)
timer:start(math.random(5, 10))
timer:start(random(5, 10))
end,
on_timer = function(pos)
@ -91,7 +93,7 @@ vines.register_vine = function( name, defs, biome )
if bottom_node.name == "air" then
if not math.random(defs.average_length) == 1 then
if not random(defs.average_length) == 1 then
minetest.set_node(pos, {
name = vine_name_middle, param2 = node.param2})
@ -101,7 +103,7 @@ vines.register_vine = function( name, defs, biome )
local timer = minetest.get_node_timer(bottom_node)
timer:start(math.random(5, 10))
timer:start(random(5, 10))
end
end
end,