Remove everything except the caves.

This commit is contained in:
Duane Robertson 2017-01-24 19:54:46 -06:00
parent e5e7475476
commit 6cb7f1da1d
205 changed files with 1251 additions and 15326 deletions

428
deco.lua
View file

@ -1,259 +1,221 @@
-- I like having different stone scattered about. Sandstone forms
-- in layers. Desert stone... doesn't exist, but let's assume it's
-- another sedementary rock and place it similarly.
minetest.register_ore({ore_type="sheet", ore="default:sandstone", wherein="default:stone", clust_num_ores=250, clust_scarcity=60, clust_size=10, y_min=-1000, y_max=31000, noise_threshold=0.1, noise_params={offset=0, scale=1, spread={x=256, y=256, z=256}, seed=4130293965, octaves=5, persist=0.60}, random_factor=1.0})
minetest.register_ore({ore_type="sheet", ore="default:desert_stone", wherein="default:stone", clust_num_ores=250, clust_scarcity=60, clust_size=10, y_min=-1000, y_max=31000, noise_threshold=0.1, noise_params={offset=0, scale=1, spread={x=256, y=256, z=256}, seed=163281090, octaves=5, persist=0.60}, random_factor=1.0})
-- Fun_Caves deco.lua
-- Copyright Duane Robertson (duane@duanerobertson.com), 2017
-- Distributed under the LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
if not fun_caves.breakable_wood then
print('* Fun Caves: Wood is NOT breakable by hand.')
for _, item in pairs(minetest.registered_items) do
if item.groups.tree or item.groups.wood then
local groups = table.copy(item.groups)
groups.oddly_breakable_by_hand = nil
minetest.override_item(item.name, {groups=groups})
end
end
end
dofile(fun_caves_mod.path .. "/nodes.lua")
dofile(fun_caves_mod.path .. "/fungal_tree.lua")
minetest.register_node("fun_caves:sand_with_rocks", {
description = "Sand and rocks",
tiles = {"fun_caves_sand_with_rocks.png"},
groups = {crumbly = 3, falling_node = 1, sand = 1},
sounds = default.node_sound_sand_defaults(),
drop = {max_items=2, items={{items={"fun_caves:small_rocks"}, rarity=1}, {items={"default:sand"}, rarity=1}}},
})
minetest.register_craft({
output = "default:stick 2",
recipe = {
{"group:sapling"}
}
})
minetest.register_craft({
output = "default:stick 2",
recipe = {
{"default:cactus"}
}
})
--minetest.add_group("default:cactus", {oddly_breakable_by_hand=1})
local deco_depth = -30 -- place cave stuff this far beneath the surface
local water_level = 1
local fluid_compression = -200 -- the depth to start planting lava/water
local max_depth = 31000
if fun_caves.use_bi_hi then
local biome_mod = {
coniferous_forest_dunes = { heat_point = 35, humidity_point = 60, },
coniferous_forest = { heat_point = 35, humidity_point = 60, },
coniferous_forest_ocean = { heat_point = 35, humidity_point = 60, },
deciduous_forest = { heat_point = 60, humidity_point = 60, },
deciduous_forest_ocean = { heat_point = 60, humidity_point = 60, },
deciduous_forest_swamp = { heat_point = 60, humidity_point = 60, },
desert = { heat_point = 80, humidity_point = 10, },
desert_ocean = { heat_point = 80, humidity_point = 10, },
glacier = {},
glacier_ocean = {},
rainforest = { heat_point = 85, humidity_point = 70, },
rainforest_ocean = { heat_point = 85, humidity_point = 70, },
rainforest_swamp = { heat_point = 85, humidity_point = 70, },
sandstone_grassland_dunes = { heat_point = 55, humidity_point = 40, },
sandstone_grassland = { heat_point = 55, humidity_point = 40, },
sandstone_grassland_ocean = { heat_point = 55, humidity_point = 40, },
savanna = { heat_point = 80, humidity_point = 25, },
savanna_ocean = { heat_point = 80, humidity_point = 25, },
savanna_swamp = { heat_point = 80, humidity_point = 25, },
stone_grassland_dunes = { heat_point = 35, humidity_point = 40, },
stone_grassland = { heat_point = 35, humidity_point = 40, },
stone_grassland_ocean = { heat_point = 35, humidity_point = 40, },
taiga = {},
taiga_ocean = {},
tundra = { node_river_water = "fun_caves:thin_ice", },
tundra_beach = { node_river_water = "fun_caves:thin_ice", },
tundra_ocean = {},
}
local rereg = {}
for n, bi in pairs(biome_mod) do
for i, rbi in pairs(minetest.registered_biomes) do
if rbi.name == n then
rereg[#rereg+1] = table.copy(rbi)
for j, prop in pairs(bi) do
rereg[#rereg][j] = prop
end
end
end
end
minetest.clear_registered_biomes()
for _, bi in pairs(rereg) do
minetest.register_biome(bi)
end
rereg = {}
for _, dec in pairs(minetest.registered_decorations) do
rereg[#rereg+1] = dec
end
minetest.clear_registered_decorations()
for _, dec in pairs(rereg) do
minetest.register_decoration(dec)
end
rereg = nil
local csize
local node_match_cache = {}
minetest.register_biome({
name = "desertstone_grassland",
--node_dust = "",
node_top = "default:dirt_with_grass",
depth_top = 1,
node_filler = "default:dirt",
depth_filler = 1,
node_stone = "default:desert_stone",
node_riverbed = "default:sand",
depth_riverbed = 2,
--node_water_top = "",
--depth_water_top = ,
--node_water = "",
--node_river_water = "",
y_min = 6,
y_max = 31000,
heat_point = 80,
humidity_point = 55,
})
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = 903, octaves = 3, persist = 0.5, lacunarity = 2.0}
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt_with_grass"},
sidelen = 80,
fill_ratio = 0.1,
biomes = {"desertstone_grassland", },
y_min = 1,
y_max = 31000,
decoration = "default:junglegrass",
})
end
-- Create and initialize a table for a schematic.
function fun_caves.schematic_array(width, height, depth)
if not (width and height and depth and type(width) == 'number' and type(height) == 'number' and type(depth) == 'number') then
-- Air needs to be placed prior to decorations.
fun_caves_mod.decogen = function(minp, maxp, data, area, node, heightmap)
if not (minp and maxp and data and area and node and type(data) == 'table' and fun_caves_mod.cave_biomes and fun_caves_mod.make_fungal_tree) then
return
end
-- Dimensions of data array.
local s = {size={x=width, y=height, z=depth}}
s.data = {}
csize = vector.add(vector.subtract(maxp, minp), 1)
for z = 0,depth-1 do
for y = 0,height-1 do
for x = 0,width-1 do
local i = z*width*height + y*width + x + 1
s.data[i] = {}
s.data[i].name = "air"
s.data[i].param1 = 000
end
end
end
local map_max = {x = csize.x, y = csize.y + 2, z = csize.z}
local map_min = {x = minp.x, y = minp.y - 1, z = minp.z}
s.yslice_prob = {}
local biome_n = minetest.get_perlin_map(biome_noise, map_max):get3dMap_flat(map_min)
return s
end
local write
local index = 0
local index3d = 0
local math_max = math.max
local math_min = math.min
local math_log = math.log
local math_random = math.random
fun_caves.schematics = {}
do
local w, h, d = 5, 8, 5
local s = fun_caves.schematic_array(w, h, d)
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
index = index + 1
index3d = (z - minp.z) * (csize.y + 2) * csize.x + (x - minp.x) + 1
local ivm = area:index(x, minp.y, z)
local height = heightmap[index]
for y = 0, math.floor(h/2)-1 do
s.data[2*d*h + y*d + 2 + 1].name = 'default:tree'
s.data[2*d*h + y*d + 2 + 1].param1 = 255
end
for y = minp.y-1, maxp.y+1 do
if y <= height + deco_depth and (height < max_depth or y < 0) then
for deco_non_loop = 1, 1 do
if not (data[ivm] == node["air"] or data[ivm] == node["default:stone"]) then
break
end
for z = 0, d-1 do
for y = math.floor(h/2), h-1 do
for x = 0, w-1 do
if y < h - 1 or (x ~= 0 and x ~= w-1 and z ~= 0 and z ~= d-1) then
if math.random(2) == 1 then
s.data[z*d*h + y*d + x + 1].name = 'fun_caves:leaves_black'
else
s.data[z*d*h + y*d + x + 1].name = 'fun_caves:sticks_default'
end
if y == h-1 or x == 0 or x == w-1 or z == 0 or z == d-1 then
s.data[z*d*h + y*d + x + 1].param1 = 150
else
s.data[z*d*h + y*d + x + 1].param1 = 225
local biome
local biome_val = biome_n[index3d]
-- Compress biomes at the surface to avoid fluids.
if y > fluid_compression then
biome_val = biome_val / math_max(1, math_log(y - fluid_compression))
end
for _, bi in pairs(fun_caves_mod.cave_biomes) do
if biome_val >= bi.biome_val_low and biome_val < bi.biome_val_high then
biome = bi
end
end
--biome = fun_caves_mod.cave_biomes['salt']
if not biome then
print(("* Fun Caves: Error in biome selection: %s"):format(biome_val))
biome = fun_caves_mod.cave_biomes['algae']
end
local node_below
if y > minp.y then
node_below = data[ivm - area.ystride]
end
local node_above = data[ivm + area.ystride]
if data[ivm] == node["default:stone"] then
if node_above == node["air"] and biome and biome.dirt and math_random(biome.dirt_chance) == 1 then
data[ivm] = node[biome.dirt]
write = true
break
end
local air_above = false
for i = 1, biome.stone_depth do
if data[ivm + area.ystride * i] == node["air"] then
air_above = true
end
end
if air_above then
if biome and biome.deco and math_random(biome.deco_chance) == 1 then
data[ivm] = node[biome.deco]
write = true
break
else
data[ivm] = node[biome.floor_node]
write = true
break
end
end
local air_below = false
for i = 1, biome.stone_depth do
if data[ivm - area.ystride * i] == node["air"] then
air_below = true
end
end
-- Prevent server-crashing sandslides.
if not air_above and biome.floor_node == "default:sand" then
data[ivm] = node["default:sandstone"]
write = true
break
end
if air_below then
if biome and biome.deco and math_random(biome.deco_chance) == 1 then
data[ivm] = node[biome.deco]
write = true
break
else
data[ivm] = node[biome.ceiling_node]
write = true
break
end
end
end
if data[ivm] == node["air"] and y < maxp.y then
-- hanging down
-- stone hasn't yet been changed
if biome and biome.stalactite and node_above == node["default:stone"] and math_random(biome.stalactite_chance) == 1 then
data[ivm] = node[biome.stalactite]
write = true
break
end
-- fluids
if y > minp.y and biome and biome.fluid and node_below == node[biome.floor_node] and math_random(biome.fluid_chance) == 1 then
data[ivm] = node[biome.fluid]
write = true
break
-- standing up
elseif node_below == node[biome.floor_node] and biome and biome.stalagmite and math_random(biome.stalagmite_chance) == 1 then
if type(biome.stalagmite) == 'table' then
data[ivm] = node[biome.stalagmite[math_random(#biome.stalagmite)]]
else
data[ivm] = node[biome.stalagmite]
end
write = true
break
-- vegetation
elseif node_below == node["default:dirt"] and biome and biome.fungi then
if math_random(10) == 1 then
data[ivm] = node["flowers:mushroom_red"]
write = true
break
elseif math_random(10) == 1 then
data[ivm] = node["flowers:mushroom_brown"]
write = true
break
elseif node_above == node["air"] and math_random(10) == 1 then
data[ivm] = node["fun_caves:giant_mushroom_stem"]
write = true
break
elseif math_random(30) == 1 then
local air_count = 0
local j
for i = 1, 12 do
j = ivm + area.ystride * i
if j <= #data and data[j] == node["air"] then
air_count = air_count + 1
end
end
if air_count > 5 then
fun_caves_mod.make_fungal_tree(data, area, ivm, math_random(2, math_min(air_count, 12)))
end
end
elseif node_below == node["fun_caves:giant_mushroom_stem"] and data[ivm - area.ystride * 2] == node["fun_caves:giant_mushroom_stem"] then
data[ivm] = node["fun_caves:giant_mushroom_cap"]
write = true
break
elseif node_below == node["fun_caves:giant_mushroom_stem"] then
if node_above == node["air"] and math_random(3) == 1 then
data[ivm] = node["fun_caves:giant_mushroom_stem"]
write = true
break
else
data[ivm] = node["fun_caves:huge_mushroom_cap"]
write = true
break
end
end
end
end
elseif y < height and data[ivm] == node["air"] and (data[ivm - area.ystride] == node['default:stone'] or data[ivm - area.ystride] == node['default:sandstone']) then
-- This just places non-abm dirt inside caves.
-- Its value is questionable.
data[ivm - area.ystride] = node["fun_caves:dirt"]
write = true
end
ivm = ivm + area.ystride
index3d = index3d + csize.x
end
end
end
for z = math.floor(d/2)-1, math.floor(d/2)+1, 2 do
for x = math.floor(w/2)-1, math.floor(w/2)+1, 2 do
s.data[z*d*h + math.floor(h/2)*d + x + 1].name = 'default:tree'
s.data[z*d*h + math.floor(h/2)*d + x + 1].param1 = 150
end
end
for y = 0, h-1 do
if y / 3 == math.floor(y / 3) then
s.yslice_prob[#s.yslice_prob+1] = {ypos=y,prob=170}
end
end
fun_caves.schematics['decaying_tree'] = s
end
do
local w, h, d = 5, 8, 5
local s = fun_caves.schematic_array(w, h, d)
for y = 0, math.floor(h/2)-1 do
s.data[2*d*h + y*d + 2 + 1].name = 'fun_caves:lumin_tree'
s.data[2*d*h + y*d + 2 + 1].param1 = 255
end
for z = 0, d-1 do
for y = math.floor(h/2), h-1 do
for x = 0, w-1 do
if y < h - 1 or (x ~= 0 and x ~= w-1 and z ~= 0 and z ~= d-1) then
s.data[z*d*h + y*d + x + 1].name = 'fun_caves:leaves_lumin'
if y == h-1 or x == 0 or x == w-1 or z == 0 or z == d-1 then
s.data[z*d*h + y*d + x + 1].param1 = 150
else
s.data[z*d*h + y*d + x + 1].param1 = 225
end
end
end
end
end
for z = math.floor(d/2)-1, math.floor(d/2)+1, 2 do
for x = math.floor(w/2)-1, math.floor(w/2)+1, 2 do
s.data[z*d*h + math.floor(h/2)*d + x + 1].name = 'fun_caves:lumin_tree'
s.data[z*d*h + math.floor(h/2)*d + x + 1].param1 = 150
end
end
for y = 0, h-1 do
if y / 3 == math.floor(y / 3) then
s.yslice_prob[#s.yslice_prob+1] = {ypos=y,prob=170}
end
end
fun_caves.schematics['lumin_tree'] = s
end
if fun_caves.path then
dofile(fun_caves.path .. "/deco_caves.lua")
--dofile(fun_caves.path.."/deco_dirt.lua")
dofile(fun_caves.path.."/deco_plants.lua")
dofile(fun_caves.path.."/deco_rocks.lua")
--dofile(fun_caves.path.."/deco_ferns.lua")
--dofile(fun_caves.path.."/deco_ferns_tree.lua")
return write
end