Add decorative leaves.
This commit is contained in:
parent
9cb5aef679
commit
3f0b5d08b2
2 changed files with 29 additions and 29 deletions
|
@ -404,8 +404,8 @@ local function generate(p_minp, p_maxp, seed)
|
||||||
else
|
else
|
||||||
-- set_lighting causes lighting artifacts,
|
-- set_lighting causes lighting artifacts,
|
||||||
-- but corrects the light inside trees.
|
-- but corrects the light inside trees.
|
||||||
vm:set_lighting({day = 0, night = 0})
|
vm:set_lighting({day = 0, night = 0}, minp, maxp)
|
||||||
vm:calc_lighting()
|
vm:calc_lighting(minp, maxp)
|
||||||
-- Does not work:
|
-- Does not work:
|
||||||
--vm:calc_lighting({x=minp.x,y=emin.y,z=minp.z}, maxp)
|
--vm:calc_lighting({x=minp.x,y=emin.y,z=minp.z}, maxp)
|
||||||
end
|
end
|
||||||
|
|
52
treegen.lua
52
treegen.lua
|
@ -4,6 +4,7 @@ local max = math.max
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
local abs = math.abs
|
local abs = math.abs
|
||||||
|
local sqrt = math.sqrt
|
||||||
local max_depth = 31000
|
local max_depth = 31000
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,27 +50,17 @@ minetest.register_node("fun_caves:petrified_wood", {
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("fun_caves:leaves", {
|
newnode = fun_caves.clone_node("default:leaves")
|
||||||
description = "Leaves",
|
newnode.tiles = {"default_leaves.png^[noalpha"}
|
||||||
visual_scale = 1.3,
|
newnode.special_tiles = nil
|
||||||
tiles = {"default_leaves.png^[noalpha"},
|
newnode.groups.leafdecay = 0
|
||||||
paramtype = "light",
|
newnode.drawtype = nil
|
||||||
is_ground_content = false,
|
newnode.waving = nil
|
||||||
groups = {snappy = 3, flammable = 2},
|
minetest.register_node("fun_caves:leaves", newnode)
|
||||||
drop = {
|
|
||||||
max_items = 1,
|
-- save for special occasions
|
||||||
items = {
|
newnode = fun_caves.clone_node("fun_caves:leaves")
|
||||||
{
|
minetest.register_node("fun_caves:leaves_special", newnode)
|
||||||
items = {'default:sapling'},
|
|
||||||
rarity = 20,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
items = {'default:leaves'},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
newnode = fun_caves.clone_node("default:water_source")
|
newnode = fun_caves.clone_node("default:water_source")
|
||||||
newnode.description = "Water"
|
newnode.description = "Water"
|
||||||
|
@ -201,7 +192,7 @@ local wood_noise = {offset = 0, scale = 1, seed = -4640, spread = {x = 32, y = 3
|
||||||
|
|
||||||
fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
||||||
local tree_n = minetest.get_perlin(tree_noise_1):get2d({x=floor((minp.x + 32) / 160) * 80, y=floor((minp.z + 32) / 160) * 80})
|
local tree_n = minetest.get_perlin(tree_noise_1):get2d({x=floor((minp.x + 32) / 160) * 80, y=floor((minp.z + 32) / 160) * 80})
|
||||||
if minp.y < -112 or minp.y > 208 or (not fun_caves.DEBUG and tree_n < 0.5) then
|
if minp.y < -112 or minp.y > 208 or (not fun_caves.DEBUG and tree_n < 1) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -224,6 +215,7 @@ fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
|
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
|
||||||
local ivm = area:index(x, minp.y - 1, z)
|
local ivm = area:index(x, minp.y - 1, z)
|
||||||
|
local distance = floor(sqrt(dx ^ 2 + dz ^ 2))
|
||||||
|
|
||||||
for y = minp.y - 1, maxp.y + 1 do
|
for y = minp.y - 1, maxp.y + 1 do
|
||||||
local dy = y - minp.y
|
local dy = y - minp.y
|
||||||
|
@ -232,7 +224,11 @@ fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
||||||
r = max(0, r - floor((abs(y - 50) - 130) / 2))
|
r = max(0, r - floor((abs(y - 50) - 130) / 2))
|
||||||
end
|
end
|
||||||
|
|
||||||
local distance = floor(math.sqrt(dx ^ 2 + dz ^ 2))
|
local distance3
|
||||||
|
if y > 112 then
|
||||||
|
distance3 = floor(sqrt(dx ^ 2 + dz ^ 2 + (y - 192) ^ 2))
|
||||||
|
end
|
||||||
|
|
||||||
if distance < r then
|
if distance < r then
|
||||||
if distance % 8 == 7 and wood_1[index3d] < 0.3 then
|
if distance % 8 == 7 and wood_1[index3d] < 0.3 then
|
||||||
data[ivm] = node['fun_caves:petrified_wood']
|
data[ivm] = node['fun_caves:petrified_wood']
|
||||||
|
@ -256,20 +252,24 @@ fun_caves.treegen = function(minp, maxp, data, p2data, area, node)
|
||||||
data[ivm] = node['fun_caves:sap']
|
data[ivm] = node['fun_caves:sap']
|
||||||
end
|
end
|
||||||
write = true
|
write = true
|
||||||
elseif y < 222 and y > -132 and floor(dx ^ 2 + dz ^ 2) < (r + 2) ^ 2 then
|
elseif y < 222 and y > -132 and distance < r + 2 then
|
||||||
data[ivm] = node['fun_caves:bark']
|
data[ivm] = node['fun_caves:bark']
|
||||||
write = true
|
write = true
|
||||||
|
|
||||||
-- foliage
|
-- foliage
|
||||||
elseif y < 272 and y > 112 and floor(dx ^ 2 + dz ^ 2 + (y - 192) ^ 2) < r2 ^ 2 and y % 10 == 0 and (floor(dx / 4) % 3 == 0 or floor(dz / 4) % 3 == 0) then
|
elseif y < 272 and y > 112 and distance3 and distance3 < r2 and y % 10 == 0 and (floor(dx / 4) % 3 == 0 or floor(dz / 4) % 3 == 0) then
|
||||||
if data[ivm] == node['air'] then
|
if data[ivm] == node['air'] then
|
||||||
data[ivm] = node['fun_caves:bark']
|
data[ivm] = node['fun_caves:bark']
|
||||||
write = true
|
write = true
|
||||||
end
|
end
|
||||||
elseif y < 275 and y > 115 and floor(dx ^ 2 + dz ^ 2 + (y - 192) ^ 2) < r2 ^ 2 and (y + 3) % 10 < 7 and (floor((dx + 3) / 4) % 3 < 2 or floor((dz + 3) / 4) % 3 < 2) then
|
elseif y < 275 and y > 115 and distance3 and distance3 < r2 and (y + 3) % 10 < 7 and (floor((dx + 3) / 4) % 3 < 2 or floor((dz + 3) / 4) % 3 < 2) then
|
||||||
local r = abs(((y + 3) % 10) - 3)
|
local r = abs(((y + 3) % 10) - 3)
|
||||||
if (r < 2 or rand(r) == 1) and data[ivm] == node['air'] then
|
if (r < 2 or rand(r) == 1) and data[ivm] == node['air'] then
|
||||||
|
if distance3 > r2 - 10 and rand(10) == 1 then
|
||||||
|
data[ivm] = node['fun_caves:leaves_special']
|
||||||
|
else
|
||||||
data[ivm] = node['fun_caves:leaves']
|
data[ivm] = node['fun_caves:leaves']
|
||||||
|
end
|
||||||
write = true
|
write = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue