235 lines
7.4 KiB
Lua
235 lines
7.4 KiB
Lua
|
|
local newnode = fun_caves.clone_node("default:dirt")
|
|
newnode.description = "Cloud"
|
|
newnode.tiles = {'fun_caves_cloud.png'}
|
|
newnode.sunlight_propagates = true
|
|
minetest.register_node("fun_caves:cloud", newnode)
|
|
|
|
newnode = fun_caves.clone_node("default:dirt")
|
|
newnode.description = "Storm Cloud"
|
|
newnode.tiles = {'fun_caves_storm_cloud.png'}
|
|
--newnode.sunlight_propagates = true
|
|
minetest.register_node("fun_caves:storm_cloud", newnode)
|
|
|
|
minetest.register_node("fun_caves:wispy_cloud", {
|
|
description = "Wispy Cloud",
|
|
tiles = {'fun_caves_wisp.png'},
|
|
sunlight_propagates = true,
|
|
use_texture_alpha = true,
|
|
drawtype = "glasslike",
|
|
paramtype = 'light',
|
|
walkable = false,
|
|
buildable_to = true,
|
|
pointable = false,
|
|
})
|
|
|
|
minetest.register_node("fun_caves:moon_weed", {
|
|
description = "Moon Weed",
|
|
drawtype = "plantlike",
|
|
tiles = {"fun_caves_moon_weed.png"},
|
|
inventory_image = "fun_caves_moon_weed.png",
|
|
waving = false,
|
|
sunlight_propagates = true,
|
|
paramtype = "light",
|
|
light_source = 8,
|
|
walkable = false,
|
|
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
selection_box = {
|
|
type = "fixed",
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
|
},
|
|
})
|
|
|
|
minetest.register_node("fun_caves:leaves_lumin", {
|
|
description = "Leaves",
|
|
drawtype = "allfaces_optional",
|
|
waving = 1,
|
|
visual_scale = 1.3,
|
|
tiles = {"default_leaves.png^[colorize:#FFDF00:150"},
|
|
special_tiles = {"default_leaves_simple.png^[colorize:#FFDF00:150"},
|
|
paramtype = "light",
|
|
is_ground_content = false,
|
|
light_source = 8,
|
|
groups = {snappy = 3, leafdecay = 4, flammable = 2, leaves = 1},
|
|
drop = {
|
|
max_items = 1,
|
|
items = {
|
|
--{
|
|
-- -- player will get sapling with 1/20 chance
|
|
-- items = {'default:sapling'},
|
|
-- rarity = 20,
|
|
--},
|
|
{
|
|
-- player will get leaves only if he get no saplings,
|
|
-- this is because max_items is 1
|
|
items = {'fun_caves:leaves_lumin'},
|
|
}
|
|
}
|
|
},
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
after_place_node = default.after_place_leaves,
|
|
})
|
|
|
|
minetest.register_node("fun_caves:lumin_tree", {
|
|
description = "Lumin Tree",
|
|
tiles = {
|
|
"default_tree_top.png", "default_tree_top.png", "fun_caves_lumin_tree.png"
|
|
},
|
|
paramtype = "light",
|
|
drawtype = "nodebox",
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = { {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}, }
|
|
},
|
|
paramtype2 = "facedir",
|
|
is_ground_content = false,
|
|
groups = {tree = 1, choppy = 2, flammable = 2},
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
on_place = minetest.rotate_node
|
|
})
|
|
|
|
newnode = fun_caves.clone_node("default:stone_with_iron")
|
|
newnode.description = "Silver Lining"
|
|
newnode.tiles = {'fun_caves_cloud.png^default_mineral_coal.png^[colorize:#FFFFFF:175'}
|
|
newnode.drop = "fun_caves:silver_lump"
|
|
minetest.register_node("fun_caves:silver_lining", newnode)
|
|
|
|
minetest.register_craftitem("fun_caves:silver_lump", {
|
|
description = "Lump of Silver",
|
|
inventory_image = 'default_coal_lump.png^[colorize:#FFFFFF:175',
|
|
})
|
|
|
|
minetest.register_craftitem("fun_caves:silver_ingot", {
|
|
description = "Silver Ingot",
|
|
inventory_image = 'default_steel_ingot.png^[colorize:#FFFFFF:175',
|
|
})
|
|
|
|
minetest.register_craft({
|
|
type = "cooking",
|
|
output = "fun_caves:silver_ingot",
|
|
recipe = "fun_caves:silver_lump",
|
|
})
|
|
|
|
|
|
local max_depth = 31000
|
|
|
|
|
|
local cloud_noise_1 = {offset = 10, scale = 10, seed = 4877, spread = {x = 120, y = 120, z = 120}, octaves = 3, persist = 1, lacunarity = 2}
|
|
local cloud_noise_2 = {offset = 0, scale = 1, seed = 5748, spread = {x = 40, y = 10, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
|
|
local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z = 200}, seed = -2525, octaves = 3, persist = 0.7, lacunarity = 2.0}
|
|
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = -1471, octaves = 3, persist = 0.5, lacunarity = 2.0}
|
|
|
|
fun_caves.cloudgen = function(minp, maxp, data, p2data, area, node)
|
|
if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table' and fun_caves.place_schematic and fun_caves.schematics and fun_caves.surround) then
|
|
return
|
|
end
|
|
|
|
if minp.y ~= 4368 then
|
|
return
|
|
end
|
|
|
|
local csize = vector.add(vector.subtract(maxp, minp), 1)
|
|
local map_max = {x = csize.x, y = csize.y, z = csize.z}
|
|
local map_min = {x = minp.x, y = minp.y, z = minp.z}
|
|
|
|
local cloud_1 = minetest.get_perlin_map(cloud_noise_1, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
|
local cloud_2 = minetest.get_perlin_map(cloud_noise_2, map_max):get3dMap_flat(map_min)
|
|
local plant_n = minetest.get_perlin_map(plant_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
|
local biome_n = minetest.get_perlin_map(biome_noise, {x=csize.x, y=csize.z}):get2dMap_flat({x=minp.x, y=minp.z})
|
|
if not (cloud_1 and cloud_2 and plant_n and biome_n) then
|
|
return
|
|
end
|
|
|
|
local write = false
|
|
|
|
local index = 0
|
|
local index3d = 0
|
|
for z = minp.z, maxp.z do
|
|
for x = minp.x, maxp.x do
|
|
index = index + 1
|
|
index3d = (z - minp.z) * (csize.y) * csize.x + (x - minp.x) + 1
|
|
local ivm = area:index(x, minp.y, z)
|
|
|
|
local cloud
|
|
if biome_n[index] < 0 then
|
|
cloud = 'storm_cloud'
|
|
else
|
|
cloud = 'cloud'
|
|
end
|
|
|
|
cloud_1[index] = math.floor(cloud_1[index] + 0.5)
|
|
for y = minp.y, maxp.y do
|
|
local dy = y - minp.y
|
|
if dy > 32 and cloud_1[index] > 15 and dy < 47 then
|
|
if dy < 48 - (cloud_1[index] - 15) then
|
|
if cloud == 'cloud' and math.random(10000) == 1 then
|
|
data[ivm] = node['fun_caves:silver_lining']
|
|
else
|
|
data[ivm] = node['fun_caves:'..cloud]
|
|
end
|
|
else
|
|
data[ivm] = node['default:water_source']
|
|
write = true
|
|
end
|
|
elseif cloud_1[index] > 0 and (dy <= 32 or cloud_1[index] <= 15) and dy >= 32 - cloud_1[index] and dy <= 32 + cloud_1[index] then
|
|
if cloud == 'cloud' and math.random(10000) == 1 then
|
|
data[ivm] = node['fun_caves:silver_lining']
|
|
else
|
|
data[ivm] = node['fun_caves:'..cloud]
|
|
end
|
|
write = true
|
|
elseif data[ivm - area.ystride] == node['fun_caves:'..cloud] and data[ivm] == node['air'] then
|
|
if math.random(30) == 1 and plant_n[index] > 0.5 then
|
|
data[ivm] = node['fun_caves:moon_weed']
|
|
write = true
|
|
elseif math.random(60) == 1 and plant_n[index] > 0.5 then
|
|
fun_caves.place_schematic(minp, maxp, data, p2data, area, node, {x=x,y=y,z=z}, fun_caves.schematics['lumin_tree'], true)
|
|
write = true
|
|
elseif math.random(10) == 1 then
|
|
data[ivm] = node['default:grass_'..math.random(4)]
|
|
write = true
|
|
end
|
|
elseif data[ivm] == node['air'] and (dy < 29 - cloud_1[index] or dy > 35 + cloud_1[index]) and cloud_2[index3d] > math.abs((dy - 40) / 20) then
|
|
data[ivm] = node['fun_caves:wispy_cloud']
|
|
write = true
|
|
end
|
|
|
|
ivm = ivm + area.ystride
|
|
index3d = index3d + csize.x
|
|
end
|
|
end
|
|
end
|
|
|
|
local index = 0
|
|
local index3d = 0
|
|
for z = minp.z, maxp.z do
|
|
for x = minp.x, maxp.x do
|
|
index = index + 1
|
|
local ivm = area:index(x, minp.y, z)
|
|
|
|
local cloud
|
|
if biome_n[index] < 0 then
|
|
cloud = 'storm_cloud'
|
|
else
|
|
cloud = 'cloud'
|
|
end
|
|
|
|
cloud_1[index] = math.floor(cloud_1[index] + 0.5)
|
|
if cloud_1[index] > 0 then
|
|
for y = minp.y, maxp.y do
|
|
local dy = y - minp.y
|
|
if data[ivm] == node['fun_caves:'..cloud] and data[ivm + area.ystride] == node['default:water_source'] and math.random(30) == 1 and fun_caves.surround(node, data, area, ivm) then
|
|
data[ivm] = node['fun_caves:water_plant_1_water_'..cloud]
|
|
end
|
|
|
|
ivm = ivm + area.ystride
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return write
|
|
end
|