--saplings
--
--
-local sapling_min = 120
-local sapling_max = 720
+--local sapling_min = 120
+--local sapling_max = 720
--make sapling grow
local function sapling_grow(pos)
if minetest.get_node_light(pos, nil) < 10 then
- local timer = minetest.get_node_timer(pos)
- timer:start(math.random(sapling_min,sapling_max))
--print("failed to grow at "..dump(pos))
return
end
end
if good_to_grow == true then
minetest.set_node(pos,{name="main:tree"})
- minetest.place_schematic(pos, treeSchematic,"0",nil,false,"place_center_x, place_center_z")
+ local schemmy = math.random(1,2)
+ if schemmy == 1 then
+ minetest.place_schematic(pos, tree_big,"0",nil,false,"place_center_x, place_center_z")
+ elseif schemmy == 2 then
+ minetest.place_schematic(pos, tree_small,"0",nil,false,"place_center_x, place_center_z")
+ end
--override leaves
- for i = 1,4 do
+ local max = 3
+ if schemmy == 2 then
+ max = 1
+ end
+ for i = 1,max do
minetest.set_node(vector.new(pos.x,pos.y+i,pos.z),{name="main:tree"})
end
end
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
- on_place = on_rightclick or function(itemstack, placer, pointed_thing)
+ on_place = function(itemstack, placer, pointed_thing)
if not pointed_thing.type == "node" then
return
end
return(itemstack)
end
end,
- on_construct = function(pos)
- local timer = minetest.get_node_timer(pos)
- timer:start(math.random(sapling_min,sapling_max))
- end,
- on_timer = function(pos)
+})
+
+
+--growing abm for sapling
+minetest.register_abm({
+ label = "Tree Grow",
+ nodenames = {"group:sapling"},
+ neighbors = {"group:soil"},
+ interval = 6,
+ chance = 250,
+ catch_up = true,
+ action = function(pos)
sapling_grow(pos)
end,
})