mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-22 16:09:33 +01:00
Generate vines and cocoas in v5, v7, etc., too
This commit is contained in:
parent
b34c4ad497
commit
1f40c86754
1 changed files with 95 additions and 98 deletions
|
@ -903,121 +903,118 @@ local lvm_buffer = {}
|
||||||
|
|
||||||
-- Generate cocoas and vines at jungle trees within the bounding box
|
-- Generate cocoas and vines at jungle trees within the bounding box
|
||||||
local function generate_jungle_tree_decorations(minp, maxp)
|
local function generate_jungle_tree_decorations(minp, maxp)
|
||||||
if mg_name == "v6" then
|
if maxp.y < 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos, treepos, dir
|
||||||
|
local jungletree = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungletree")
|
||||||
|
local jungleleaves = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungleleaves")
|
||||||
|
|
||||||
|
-- Pass 1: Generate cocoas
|
||||||
|
for n = 1, #jungletree do
|
||||||
|
|
||||||
|
pos = jungletree[n]
|
||||||
|
treepos = table.copy(pos)
|
||||||
|
|
||||||
|
if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then
|
||||||
|
|
||||||
|
dir = math.random(1, 40)
|
||||||
|
|
||||||
|
if dir == 1 then
|
||||||
|
pos.z = pos.z + 1
|
||||||
|
elseif dir == 2 then
|
||||||
|
pos.z = pos.z - 1
|
||||||
|
elseif dir == 3 then
|
||||||
|
pos.x = pos.x + 1
|
||||||
|
elseif dir == 4 then
|
||||||
|
pos.x = pos.x -1
|
||||||
|
end
|
||||||
|
|
||||||
|
local nn = minetest.get_node(pos).name
|
||||||
|
|
||||||
|
if dir < 5
|
||||||
|
and nn == "air"
|
||||||
|
and minetest.get_node_light(pos) > 12 then
|
||||||
|
minetest.swap_node(pos, {
|
||||||
|
name = "mcl_cocoas:cocoa_" .. tostring(math.random(1, 3)),
|
||||||
|
param2 = minetest.dir_to_facedir(vector.subtract(treepos, pos))
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
if maxp.y < 0 then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local pos, treepos, dir
|
-- Pass 2: Generate vines at jungle wood and jungle leaves
|
||||||
local jungletree = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungletree")
|
perlin_vines = perlin_vines or minetest.get_perlin(555, 4, 0.6, 500)
|
||||||
local jungleleaves = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungleleaves")
|
perlin_vines_fine = perlin_vines_fine or minetest.get_perlin(43000, 3, 0.6, 1)
|
||||||
|
perlin_vines_length = perlin_vines_length or minetest.get_perlin(435, 4, 0.6, 75)
|
||||||
|
perlin_vines_upwards = perlin_vines_upwards or minetest.get_perlin(436, 3, 0.6, 10)
|
||||||
|
perlin_vines_density = perlin_vines_density or minetest.get_perlin(436, 3, 0.6, 500)
|
||||||
|
local junglething
|
||||||
|
for i=1, 2 do
|
||||||
|
if i==1 then junglething = jungletree
|
||||||
|
else junglething = jungleleaves end
|
||||||
|
|
||||||
-- Pass 1: Generate cocoas
|
for n = 1, #junglething do
|
||||||
for n = 1, #jungletree do
|
pos = junglething[n]
|
||||||
|
|
||||||
pos = jungletree[n]
|
|
||||||
treepos = table.copy(pos)
|
treepos = table.copy(pos)
|
||||||
|
|
||||||
if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then
|
local dirs = {
|
||||||
|
{x=1,y=0,z=0},
|
||||||
|
{x=-1,y=0,z=0},
|
||||||
|
{x=0,y=0,z=1},
|
||||||
|
{x=0,y=0,z=-1},
|
||||||
|
}
|
||||||
|
|
||||||
dir = math.random(1, 40)
|
for d = 1, #dirs do
|
||||||
|
local pos = vector.add(pos, dirs[d])
|
||||||
|
|
||||||
if dir == 1 then
|
local nn = minetest.get_node(pos).name
|
||||||
pos.z = pos.z + 1
|
|
||||||
elseif dir == 2 then
|
|
||||||
pos.z = pos.z - 1
|
|
||||||
elseif dir == 3 then
|
|
||||||
pos.x = pos.x + 1
|
|
||||||
elseif dir == 4 then
|
|
||||||
pos.x = pos.x -1
|
|
||||||
end
|
|
||||||
|
|
||||||
local nn = minetest.get_node(pos).name
|
if perlin_vines:get2d(pos) > 0.1 and perlin_vines_fine:get3d(pos) > math.max(0.3333, perlin_vines_density:get2d(pos)) and nn == "air" then
|
||||||
|
|
||||||
if dir < 5
|
local newnode = {
|
||||||
and nn == "air"
|
name = "mcl_core:vine",
|
||||||
and minetest.get_node_light(pos) > 12 then
|
param2 = minetest.dir_to_wallmounted(vector.subtract(treepos, pos))
|
||||||
minetest.swap_node(pos, {
|
|
||||||
name = "mcl_cocoas:cocoa_" .. tostring(math.random(1, 3)),
|
|
||||||
param2 = minetest.dir_to_facedir(vector.subtract(treepos, pos))
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Pass 2: Generate vines at jungle wood and jungle leaves
|
|
||||||
perlin_vines = perlin_vines or minetest.get_perlin(555, 4, 0.6, 500)
|
|
||||||
perlin_vines_fine = perlin_vines_fine or minetest.get_perlin(43000, 3, 0.6, 1)
|
|
||||||
perlin_vines_length = perlin_vines_length or minetest.get_perlin(435, 4, 0.6, 75)
|
|
||||||
perlin_vines_upwards = perlin_vines_upwards or minetest.get_perlin(436, 3, 0.6, 10)
|
|
||||||
perlin_vines_density = perlin_vines_density or minetest.get_perlin(436, 3, 0.6, 500)
|
|
||||||
local junglething
|
|
||||||
for i=1, 2 do
|
|
||||||
if i==1 then junglething = jungletree
|
|
||||||
else junglething = jungleleaves end
|
|
||||||
|
|
||||||
for n = 1, #junglething do
|
|
||||||
pos = junglething[n]
|
|
||||||
|
|
||||||
treepos = table.copy(pos)
|
|
||||||
|
|
||||||
local dirs = {
|
|
||||||
{x=1,y=0,z=0},
|
|
||||||
{x=-1,y=0,z=0},
|
|
||||||
{x=0,y=0,z=1},
|
|
||||||
{x=0,y=0,z=-1},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for d = 1, #dirs do
|
-- Determine growth direction
|
||||||
local pos = vector.add(pos, dirs[d])
|
local grow_upwards = false
|
||||||
|
-- Only possible on the wood, not on the leaves
|
||||||
local nn = minetest.get_node(pos).name
|
if i == 1 then
|
||||||
|
grow_upwards = perlin_vines_upwards:get3d(pos) > 0.8
|
||||||
if perlin_vines:get2d(pos) > 0.1 and perlin_vines_fine:get3d(pos) > math.max(0.3333, perlin_vines_density:get2d(pos)) and nn == "air" then
|
end
|
||||||
|
if grow_upwards then
|
||||||
local newnode = {
|
-- Grow vines up 1-4 nodes, even through jungleleaves.
|
||||||
name = "mcl_core:vine",
|
-- This may give climbing access all the way to the top of the tree :-)
|
||||||
param2 = minetest.dir_to_wallmounted(vector.subtract(treepos, pos))
|
-- But this will be fairly rare.
|
||||||
}
|
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * 4)
|
||||||
|
for l=0, length-1 do
|
||||||
-- Determine growth direction
|
local tnn = minetest.get_node(treepos).name
|
||||||
local grow_upwards = false
|
local nn = minetest.get_node(pos).name
|
||||||
-- Only possible on the wood, not on the leaves
|
if (nn == "air" or nn == "mcl_core:jungleleaves") and mcl_core.supports_vines(tnn) then
|
||||||
if i == 1 then
|
minetest.set_node(pos, newnode)
|
||||||
grow_upwards = perlin_vines_upwards:get3d(pos) > 0.8
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
treepos.y = treepos.y + 1
|
||||||
end
|
end
|
||||||
if grow_upwards then
|
else
|
||||||
-- Grow vines up 1-4 nodes, even through jungleleaves.
|
-- Grow vines down 1-7 nodes
|
||||||
-- This may give climbing access all the way to the top of the tree :-)
|
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * 7)
|
||||||
-- But this will be fairly rare.
|
for l=0, length-1 do
|
||||||
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * 4)
|
if minetest.get_node(pos).name == "air" then
|
||||||
for l=0, length-1 do
|
minetest.set_node(pos, newnode)
|
||||||
local tnn = minetest.get_node(treepos).name
|
else
|
||||||
local nn = minetest.get_node(pos).name
|
break
|
||||||
if (nn == "air" or nn == "mcl_core:jungleleaves") and mcl_core.supports_vines(tnn) then
|
|
||||||
minetest.set_node(pos, newnode)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
treepos.y = treepos.y + 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Grow vines down 1-7 nodes
|
|
||||||
local length = math.ceil(math.abs(perlin_vines_length:get3d(pos)) * 7)
|
|
||||||
for l=0, length-1 do
|
|
||||||
if minetest.get_node(pos).name == "air" then
|
|
||||||
minetest.set_node(pos, newnode)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
pos.y = pos.y - 1
|
|
||||||
end
|
end
|
||||||
|
pos.y = pos.y - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue