Browse Source

[vines] Optimize math.random call function

master
sys4 2 weeks ago
parent
commit
1f52bbea19
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      vines/init.lua

+ 5
- 3
vines/init.lua View 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,


Loading…
Cancel
Save