[nature_classic] Optimize math.random call function

This commit is contained in:
Sys Quatre 2020-07-23 23:10:37 +02:00
부모 ec8132b06c
커밋 8d65559828
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제

파일 보기

@ -2,6 +2,8 @@
local S = minetest.get_translator("nature_classic")
-- Blossoms and such
local random = math.random
local function spawn_apple_under(pos)
local below = {
x = pos.x,
@ -46,7 +48,7 @@ minetest.register_abm({
chance = nature.leaves_blossom_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if math.random(nature.leaves_blossom_chance) == 1 then
if random(nature.leaves_blossom_chance) == 1 then
nature.enqueue_node(pos, node, nature.blossom_node)
end
end
@ -61,7 +63,7 @@ minetest.register_abm({
chance = nature.blossom_leaves_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if math.random(nature.blossom_leaves_chance) == 1 then
if random(nature.blossom_leaves_chance) == 1 then
nature.enqueue_node(pos, node, nature.blossom_leaves)
end
end
@ -76,7 +78,7 @@ minetest.register_abm({
chance = nature.apple_chance,
action = function(pos, node, active_object_count, active_object_count_wider)
if math.random(4) == 1 and nature.dtime < 0.2 and not minetest.find_node_near(pos, nature.apple_spread, { "default:apple" }) then
if random(4) == 1 and nature.dtime < 0.2 and not minetest.find_node_near(pos, nature.apple_spread, { "default:apple" }) then
spawn_apple_under(pos)
end
end