forked from mtcontrib/plantlife_modpack
[vines] Optimize math.random call function
This commit is contained in:
parent
10ff005066
commit
1f52bbea19
@ -18,6 +18,8 @@ minetest.register_craftitem("vines:vines", {
|
|||||||
|
|
||||||
-- FUNCTIONS
|
-- FUNCTIONS
|
||||||
|
|
||||||
|
local random = math.random
|
||||||
|
|
||||||
local function dig_down(pos, node, digger)
|
local function dig_down(pos, node, digger)
|
||||||
|
|
||||||
if digger == nil then return end
|
if digger == nil then return end
|
||||||
@ -80,7 +82,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
|
|
||||||
local timer = minetest.get_node_timer(pos)
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
|
||||||
timer:start(math.random(5, 10))
|
timer:start(random(5, 10))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_timer = function(pos)
|
on_timer = function(pos)
|
||||||
@ -91,7 +93,7 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
|
|
||||||
if bottom_node.name == "air" then
|
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, {
|
minetest.set_node(pos, {
|
||||||
name = vine_name_middle, param2 = node.param2})
|
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)
|
local timer = minetest.get_node_timer(bottom_node)
|
||||||
|
|
||||||
timer:start(math.random(5, 10))
|
timer:start(random(5, 10))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user