forked from DokimiCU/aotearoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrees.lua
114 lines (90 loc) · 2.94 KB
/
trees.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
local random = math.random
-----------------
-- Grow trees from saplings
--
--make sure each tree has 2 schems, and schem name is e.g. Treename1
-- Grow sapling
function aotearoa.grow_sapling(pos, treename, stem)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
else
--remove sapling.
minetest.set_node(pos, {name = stem})
--correct position for placing based on which schem is used
--large trees that all use 15x15
pos = {x = pos.x - 7, y = pos.y-1, z = pos.z - 7}
--place schematic
local chance = random(1,2)
if chance == 1 then
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."1"..".mts", random, "", false)
else
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."2"..".mts", random, "", false)
end
end
end
---------------------------
-- Grow SHRUB sapling
function aotearoa.grow_shrub_sapling(pos, treename, stem)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
else
--remove sapling.
minetest.set_node(pos, {name = stem})
--correct position for placing based on which schem is used
--shrubs use 5x5
pos = {x = pos.x - 2, y = pos.y-1, z = pos.z - 2}
--place schematic
local chance = random(1,2)
if chance == 1 then
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."1"..".mts", random, "", false)
else
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."2"..".mts", random, "", false)
end
end
end
---------------------------
-- Grow BUSH sapling
function aotearoa.grow_bush_sapling(pos, treename, stem)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
else
--remove sapling.
minetest.set_node(pos, {name = stem})
--correct position for placing based on which schem is used
--bushes use 3x3
pos = {x = pos.x - 1, y = pos.y-1, z = pos.z - 1}
--place schematic
local chance = random(1,2)
if chance == 1 then
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."1"..".mts", random, "", false)
else
minetest.place_schematic(pos, aotearoa.path.. "/schematics/"..treename.."2"..".mts", random, "", false)
end
end
end
----------------------------------
-- Grow TREE FERN sapling (also palm style)
function aotearoa.grow_tree_fern_sapling(pos, treename, stem)
if not default.can_grow(pos) then
-- try again 5 min later
minetest.get_node_timer(pos):start(300)
return
else
--remove sapling.
minetest.set_node(pos, {name = stem})
--place schematic from schematics file
local chance = random(1,2)
local schem = nil
if chance == 1 then
minetest.place_schematic(pos, aotearoa[treename.."1"])
else
minetest.place_schematic(pos, aotearoa[treename.."2"])
end
end
end