master
crazyginger72 2014-08-23 21:57:28 -04:00
parent ffcff9f0ee
commit bd07144ff4
1 changed files with 89 additions and 90 deletions

View File

@ -94,97 +94,96 @@ function default.grow_jungletree(data, a, pos, seed)
end
function default.grow_acaciatree(data, a, pos, seed) --watershed_acaciatree(x, y, z, area, data)
local c_actree = minetest.get_content_id("default:acaciatree_gen") --trunk
local c_actree2 = minetest.get_content_id("default:acaciatree_t") --limbs
local c_acleaf = minetest.get_content_id("default:acacialeaves") --leaves
local c_actree = minetest.get_content_id("default:acaciatree_gen") --trunk
local c_actree2 = minetest.get_content_id("default:acaciatree_t") --limbs
local c_acleaf = minetest.get_content_id("default:acacialeaves") --leaves
local xa = pos.x
local ya = pos.y
local za = pos.z
for j = -3, 9 do --j is the y axis level of the tree
local pr = PseudoRandom(seed)
local xa = pos.x
local ya = pos.y
local za = pos.z
for j = -3, 9 do --j is the y axis level of the tree
local th = pr:next(0, 2) --adds 0-2 to the hight of the tree
if j > 7 + th then return end --if y is not in the trees range
if j == 7 + th then --the top layer of leaves
for i = -3, 3 do --sets size of the layer
for k = -3, 3 do --sets size of the layer
if math.abs(i) + math.abs(k) ~= 6 then --makes the corners rounded off
if math.random(15) ~= 11 then --adds leaves at random
local vil = a:index(xa + i, ya + j + th, za + k) --set area for leaves
if data[vil] == c_air or data[vil] == c_ignore then --set only if air or ignore
data[vil] = c_acleaf --add leaves now
end
end
end
local th = pr:next(0, 2) --adds 0-2 to the hight of the tree
if j > 7 + th then return end --if y is not in the trees range
if j == 7 + th then --the top layer of leaves
for i = -3, 3 do --sets size of the layer
for k = -3, 3 do --sets size of the layer
if math.abs(i) + math.abs(k) ~= 6 then --makes the corners rounded off
if math.random(15) ~= 11 then --adds leaves at random
local vil = a:index(xa + i, ya + j + th, za + k) --set area for leaves
if data[vil] == c_air or data[vil] == c_ignore then --set only if air or ignore
data[vil] = c_acleaf --add leaves now
end
end
end
end
end
elseif j == 6 + th then --second layer of leaves
for i = -5, 5 do --sets size of the layer
for k = -5, 5 do --sets size of the layer
if math.abs(i) + math.abs(k) ~= 10 and math.abs(i) + math.abs(k) ~= 9 then --makes the corners rounded off
if math.random(15) ~= 2 then --adds leaves at random
local vil1 = a:index(xa + i, ya + j +th, za + k) --set area for leaves
if data[vil1] == c_air or data[vil1] == c_ignore then --set only if air or ignore
data[vil1] = c_acleaf --add leaves now
end
elseif j == 6 + th then --second layer of leaves
for i = -5, 5 do --sets size of the layer
for k = -5, 5 do --sets size of the layer
if math.abs(i) + math.abs(k) ~= 10 and math.abs(i) + math.abs(k) ~= 9 then --makes the corners rounded off
if math.random(15) ~= 2 then --adds leaves at random
local vil1 = a:index(xa + i, ya + j +th, za + k) --set area for leaves
if data[vil1] == c_air or data[vil1] == c_ignore then --set only if air or ignore
data[vil1] = c_acleaf --add leaves now
end
end
end
end
end
elseif j == 5 +th then --first layer of wood third of leaves
for i = -6, 6 do --sets size of the layer
for k = -6, 6 do --sets size of the layer
for i2 = -2, 2, 4 do --sets size of the layer-wood
for k2 = -2, 2, 4 do --sets size of the layer-wood
for i3 = -3, 3, 6 do --sets size of the layer-wood
for k3 = -3, 3, 6 do --sets size of the layer-wood
if math.abs(i) == 6 and math.abs(i) + math.abs(k) ~= 12 and math.abs(i) + math.abs(k) ~= 11 --makes the outer rim of leaves
or math.abs(k) == 6 and math.abs(i) + math.abs(k) ~= 12 and math.abs(i) + math.abs(k) ~= 11 --makes the outer rim of leaves
or math.abs(i) == 5 and math.abs(k) == 5 --makes the outer rim of leaves
or math.abs(i) == 5 and math.abs(k) == 4 --makes the outer rim of leaves
or math.abs(i) == 4 and math.abs(k) == 5 then --makes the outer rim of leaves
local vil2 = a:index(xa + i, ya + j +th, za + k) --set area for leaves
if data[vil2] == c_air or data[vil2] == c_ignore then --set only if air or ignore
data[vil2] = c_acleaf --add leaves now
end
end
local vit = a:index(xa + i2, ya + j + th, za + k2) --sets area for wood
if data[vit] == c_air or data[vit] == c_ignore or data[vit] == c_acleaf then --set only if air, leaves or ignore
data[vit] = c_actree2 --add wood now
end
local vit2 = a:index(xa + i3, ya + j + th, za + k3) --sets area for wood
if data[vit2] == c_air or data[vit2] == c_ignore or data[vit2] == c_acleaf then --set only if air, leaves or ignore
data[vit2] = c_actree2 --add wood now
end
end
end
end
end
end
end
elseif j == 4 + th then --second layer of wood
for i = -1, 1 do --sets size of the layer
for k = -1, 1 do --sets size of the layer
if math.abs(i) + math.abs(k) == 2 then --makes the patern of wood
local vit3 = a:index(xa + i, ya + j + th, za + k) --set area for wood
if data[vit3] == c_air or data[vit3] == c_ignore or data[vit3] == c_acleaf or data[vit3] then --set only if air, leaves or ignore
data[vit3] = c_actree2 --add wood now
end
end
end
end
elseif j <= -1 then --layer for roots
local vit4 = a:index(xa, ya + j , za) --set area for wood
if data[vit4] ~= c_air then --sets if not air
data[vit4] = c_actree2 --add wood now
end
else
for t = 0, th do --layer for main trunk
local vit5 = a:index(xa, ya + j + t , za) --set area for wood
if data[vit5] == c_air or data[vit5] == c_ignore or data[vit5] == c_acleaf then --set only if air, leaves or ignore
data[vit5] = c_actree --add wood now
end
end
end
end
end
end
end
end
elseif j == 5 +th then --first layer of wood third of leaves
for i = -6, 6 do --sets size of the layer
for k = -6, 6 do --sets size of the layer
for i2 = -2, 2, 4 do --sets size of the layer-wood
for k2 = -2, 2, 4 do --sets size of the layer-wood
for i3 = -3, 3, 6 do --sets size of the layer-wood
for k3 = -3, 3, 6 do --sets size of the layer-wood
if math.abs(i) == 6 and math.abs(i) + math.abs(k) ~= 12 and math.abs(i) + math.abs(k) ~= 11 --makes the outer rim of leaves
or math.abs(k) == 6 and math.abs(i) + math.abs(k) ~= 12 and math.abs(i) + math.abs(k) ~= 11 --makes the outer rim of leaves
or math.abs(i) == 5 and math.abs(k) == 5 --makes the outer rim of leaves
or math.abs(i) == 5 and math.abs(k) == 4 --makes the outer rim of leaves
or math.abs(i) == 4 and math.abs(k) == 5 then --makes the outer rim of leaves
local vil2 = a:index(xa + i, ya + j +th, za + k) --set area for leaves
if data[vil2] == c_air or data[vil2] == c_ignore then --set only if air or ignore
data[vil2] = c_acleaf --add leaves now
end
end
local vit = a:index(xa + i2, ya + j + th, za + k2) --sets area for wood
if data[vit] == c_air or data[vit] == c_ignore or data[vit] == c_acleaf then --set only if air, leaves or ignore
data[vit] = c_actree2 --add wood now
end
local vit2 = a:index(xa + i3, ya + j + th, za + k3) --sets area for wood
if data[vit2] == c_air or data[vit2] == c_ignore or data[vit2] == c_acleaf then --set only if air, leaves or ignore
data[vit2] = c_actree2 --add wood now
end
end
end
end
end
end
end
elseif j == 4 + th then --second layer of wood
for i = -1, 1 do --sets size of the layer
for k = -1, 1 do --sets size of the layer
if math.abs(i) + math.abs(k) == 2 then --makes the patern of wood
local vit3 = a:index(xa + i, ya + j + th, za + k) --set area for wood
if data[vit3] == c_air or data[vit3] == c_ignore or data[vit3] == c_acleaf or data[vit3] then --set only if air, leaves or ignore
data[vit3] = c_actree2 --add wood now
end
end
end
end
elseif j <= -1 then --layer for roots
local vit4 = a:index(xa, ya + j , za) --set area for wood
if data[vit4] ~= c_air then --sets if not air
data[vit4] = c_actree2 --add wood now
end
else
for t = 0, th do --layer for main trunk
local vit5 = a:index(xa, ya + j + t , za) --set area for wood
if data[vit5] == c_air or data[vit5] == c_ignore or data[vit5] == c_acleaf then --set only if air, leaves or ignore
data[vit5] = c_actree --add wood now
end
end
end
end
end