Skip to content

Commit

Permalink
Saplings: Reduce grow time to ABM equivalent
Browse files Browse the repository at this point in the history
Previous times were chosen using statistical maths, but reports suggested
this was too long.
I tested by timing an ABM acting on 100 nodes, with interval and chance equal
to the old sapling ABM.
50 at 4m59s.
99 at 24m58s.
100 at 26m58s.
So choose a grow time between 5 and 25 min for tree and bush saplings.
If 'can grow' is false at grow time the timer is reset to 5 min.
  • Loading branch information
paramat authored and sfan5 committed Nov 19, 2017
1 parent cafcfca commit 5186e49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions mods/default/nodes.lua
Expand Up @@ -608,7 +608,7 @@ minetest.register_node("default:sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -742,7 +742,7 @@ minetest.register_node("default:junglesapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -821,7 +821,7 @@ minetest.register_node("default:pine_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -901,7 +901,7 @@ minetest.register_node("default:acacia_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -979,7 +979,7 @@ minetest.register_node("default:aspen_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(2400,4800))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -1362,7 +1362,7 @@ minetest.register_node("default:bush_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(1200, 2400))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down Expand Up @@ -1433,7 +1433,7 @@ minetest.register_node("default:acacia_bush_sapling", {
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
minetest.get_node_timer(pos):start(math.random(1200, 2400))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end,
on_place = function(itemstack, placer, pointed_thing)
Expand Down
8 changes: 4 additions & 4 deletions mods/default/trees.lua
Expand Up @@ -31,12 +31,12 @@ local function is_snow_nearby(pos)
end


-- Sapling ABM
-- Grow sapling

function default.grow_sapling(pos)
if not default.can_grow(pos) then
-- try a bit later again
minetest.get_node_timer(pos):start(math.random(240, 600))
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
end

Expand Down Expand Up @@ -94,7 +94,7 @@ minetest.register_lbm({
"default:pine_sapling", "default:acacia_sapling",
"default:aspen_sapling"},
action = function(pos)
minetest.get_node_timer(pos):start(math.random(1200, 2400))
minetest.get_node_timer(pos):start(math.random(300, 1500))
end
})

Expand Down

0 comments on commit 5186e49

Please sign in to comment.