Skip to content

Commit

Permalink
Fir sapling grows
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelysam committed Jul 4, 2015
1 parent c041cfb commit e124267
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
13 changes: 0 additions & 13 deletions nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,6 @@ register_dirts("Sandy")
-- Trees --
-----------

local function can_grow(pos)
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return false
end
local name_under = node_under.name
local is_soil = minetest.get_item_group(name_under, "soil")
if is_soil == 0 then
return false
end
return true
end

minetest.register_node("valleys_mapgen:fir_tree", {
description = "Fir Tree",
tiles = {"vmg_fir_tree_top.png", "vmg_fir_tree_top.png", "vmg_fir_tree.png"},
Expand Down
28 changes: 28 additions & 0 deletions trees.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
local function can_grow(pos) -- from default mod
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under then
return false
end
local name_under = node_under.name
local is_soil = minetest.get_item_group(name_under, "soil")
if is_soil == 0 then
return false
end
return true
end

minetest.register_abm({
nodenames = {"valleys_mapgen:fir_sapling"},
interval = 14,
chance = 50,
action = function(pos, node)
if not can_grow(pos) then
return
end

minetest.log("action", "A fir sapling grows into a tree at "..
minetest.pos_to_string(pos))
vmg.grow_fir_tree(pos)
end
})

function default.grow_tree(pos, is_apple_tree)
local rand = math.random()
local height = math.floor(4 + 2.5 * rand)
Expand Down

0 comments on commit e124267

Please sign in to comment.