Splitting out of Caverealms after extensive modification
This commit is contained in:
commit
b77e297302
17
.gitattributes
vendored
Normal file
17
.gitattributes
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Custom for Visual Studio
|
||||||
|
*.cs diff=csharp
|
||||||
|
|
||||||
|
# Standard to msysgit
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
47
.gitignore
vendored
Normal file
47
.gitignore
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Operating System Files
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
2
depends.txt
Normal file
2
depends.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
default
|
||||||
|
intllib?
|
1
description.txt
Normal file
1
description.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
A mod that creates vast underground caverns and allows biomes to be defined for them
|
162
features.lua
Normal file
162
features.lua
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
local c_dry_stal_1 = minetest.get_content_id("subterrane:dry_stal_1") -- thinnest
|
||||||
|
local c_dry_stal_2 = minetest.get_content_id("subterrane:dry_stal_2")
|
||||||
|
local c_dry_stal_3 = minetest.get_content_id("subterrane:dry_stal_3")
|
||||||
|
local c_dry_stal_4 = minetest.get_content_id("subterrane:dry_stal_4") -- thickest
|
||||||
|
|
||||||
|
local c_wet_stal_1 = minetest.get_content_id("subterrane:wet_stal_1") -- thinnest
|
||||||
|
local c_wet_stal_2 = minetest.get_content_id("subterrane:wet_stal_2")
|
||||||
|
local c_wet_stal_3 = minetest.get_content_id("subterrane:wet_stal_3")
|
||||||
|
local c_wet_stal_4 = minetest.get_content_id("subterrane:wet_stal_4") -- thickest
|
||||||
|
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
|
local wet_stalagmite_id = {c_wet_stal_1, c_wet_stal_2, c_wet_stal_3, c_wet_stal_4}
|
||||||
|
local dry_stalagmite_id = {c_dry_stal_1, c_dry_stal_2, c_dry_stal_3, c_dry_stal_4}
|
||||||
|
|
||||||
|
-- use a negative height to turn this into a stalactite
|
||||||
|
function subterrane:stalagmite(vi, area, data, param2_data, param2, height, is_wet)
|
||||||
|
local pos = area:position(vi)
|
||||||
|
local x = pos.x
|
||||||
|
local y = pos.y
|
||||||
|
local z = pos.z
|
||||||
|
|
||||||
|
if height == nil then height = math.random(1,4) end
|
||||||
|
if param2 == nil then param2 = math.random(0,3) end
|
||||||
|
|
||||||
|
local stalagmite_id = nil
|
||||||
|
if is_wet then stalagmite_id = wet_stalagmite_id else stalagmite_id = dry_stalagmite_id end
|
||||||
|
|
||||||
|
local sign, id_modifier
|
||||||
|
if height > 0 then
|
||||||
|
sign = 1
|
||||||
|
id_modifier = 1 -- stalagmites are blunter than stalactites
|
||||||
|
else
|
||||||
|
sign = -1
|
||||||
|
id_modifier = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, math.abs(height) do
|
||||||
|
vi = area:index(x, y + height - i * sign, z)
|
||||||
|
if data[vi] == c_air then
|
||||||
|
data[vi] = stalagmite_id[math.min(i+id_modifier,4)]
|
||||||
|
param2_data[vi] = param2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--giant stalagmite spawner
|
||||||
|
function subterrane:giant_stalagmite(vi, area, data, min_height, max_height, base_material, root_material, shaft_material)
|
||||||
|
local pos = area:position(vi)
|
||||||
|
local x = pos.x
|
||||||
|
local y = pos.y
|
||||||
|
local z = pos.z
|
||||||
|
|
||||||
|
local top = math.random(min_height,max_height)
|
||||||
|
for j = -2, top do --y
|
||||||
|
for k = -3, 3 do
|
||||||
|
for l = -3, 3 do
|
||||||
|
if j <= 0 then
|
||||||
|
if k*k + l*l <= 9 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
if data[vi] == c_air then data[vi] = base_material end
|
||||||
|
end
|
||||||
|
elseif j <= top/5 then
|
||||||
|
if k*k + l*l <= 4 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
data[vi] = root_material
|
||||||
|
end
|
||||||
|
elseif j <= top/5 * 3 then
|
||||||
|
if k*k + l*l <= 1 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
data[vi] = shaft_material
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local vi = area:index(x, y+j, z)
|
||||||
|
data[vi] = shaft_material
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--giant stalactite spawner
|
||||||
|
function subterrane:giant_stalactite(vi, area, data, min_height, max_height, base_material, root_material, shaft_material)
|
||||||
|
local pos = area:position(vi)
|
||||||
|
local x = pos.x
|
||||||
|
local y = pos.y
|
||||||
|
local z = pos.z
|
||||||
|
|
||||||
|
local bot = math.random(-max_height, -min_height) --grab a random height for the stalagmite
|
||||||
|
for j = bot, 2 do --y
|
||||||
|
for k = -3, 3 do
|
||||||
|
for l = -3, 3 do
|
||||||
|
if j >= -1 then
|
||||||
|
if k*k + l*l <= 9 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
if data[vi] == c_air then data[vi] = base_material end
|
||||||
|
end
|
||||||
|
elseif j >= bot/5 then
|
||||||
|
if k*k + l*l <= 4 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
data[vi] = root_material
|
||||||
|
end
|
||||||
|
elseif j >= bot/5 * 3 then
|
||||||
|
if k*k + l*l <= 1 then
|
||||||
|
local vi = area:index(x+k, y+j, z+l)
|
||||||
|
data[vi] = shaft_material
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local vi = area:index(x, y+j, z)
|
||||||
|
data[vi] = shaft_material
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--function to create giant 'shrooms. Cap radius works well from about 2-6
|
||||||
|
function subterrane:giant_shroom(vi, area, data, stem_material, cap_material, gill_material, stem_height, cap_radius)
|
||||||
|
local pos = area:position(vi)
|
||||||
|
local x = pos.x
|
||||||
|
local y = pos.y
|
||||||
|
local z = pos.z
|
||||||
|
|
||||||
|
--cap
|
||||||
|
for k = -cap_radius, cap_radius do
|
||||||
|
for l = -cap_radius, cap_radius do
|
||||||
|
if k*k + l*l <= cap_radius*cap_radius then
|
||||||
|
local vi = area:index(x+k, y+stem_height, z+l)
|
||||||
|
if data[vi] == c_air then data[vi] = cap_material end
|
||||||
|
end
|
||||||
|
if k*k + l*l <= (cap_radius-1)*(cap_radius-1) and (cap_radius-1) > 0 then
|
||||||
|
local vi = area:index(x+k, y+stem_height+1, z+l)
|
||||||
|
data[vi] = cap_material
|
||||||
|
vi = area:index(x+k, y+stem_height, z+l)
|
||||||
|
if data[vi] == cap_material then data[vi] = gill_material end
|
||||||
|
end
|
||||||
|
if k*k + l*l <= (cap_radius-2)*(cap_radius-2) and (cap_radius-2) > 0 then
|
||||||
|
local vi = area:index(x+k, y+stem_height+2, z+l)
|
||||||
|
if data[vi] == c_air then data[vi] = cap_material end
|
||||||
|
end
|
||||||
|
if k*k + l*l <= (cap_radius-3)*(cap_radius-3) and (cap_radius-3) > 0 then
|
||||||
|
local vi = area:index(x+k, y+stem_height+3, z+l)
|
||||||
|
if data[vi] == c_air then data[vi] = cap_material end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--stem
|
||||||
|
for j = -1, stem_height do
|
||||||
|
local vi = area:index(x, y+j, z)
|
||||||
|
data[vi] = stem_material
|
||||||
|
if cap_radius > 3 then
|
||||||
|
local ai = area:index(x, y+j, z+1)
|
||||||
|
if data[ai] == c_air then data[ai] = stem_material end
|
||||||
|
ai = area:index(x, y+j, z-1)
|
||||||
|
if data[ai] == c_air then data[ai] = stem_material end
|
||||||
|
ai = area:index(x+1, y+j, z)
|
||||||
|
if data[ai] == c_air then data[ai] = stem_material end
|
||||||
|
ai = area:index(x-1, y+j, z)
|
||||||
|
if data[ai] == c_air then data[ai] = stem_material end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
40
functions.lua
Normal file
40
functions.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
--subterrane functions.lua
|
||||||
|
|
||||||
|
--FUNCTIONS--
|
||||||
|
|
||||||
|
function subterrane:vertically_consistent_random(vi, area)
|
||||||
|
local pos = area:position(vi)
|
||||||
|
local next_seed = math.random(1, 1000000000)
|
||||||
|
math.randomseed(pos.x + pos.z * 2 ^ 8)
|
||||||
|
local output = math.random()
|
||||||
|
math.randomseed(next_seed)
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Unfortunately there's no easy way to override a single biome, so do it by wiping everything and re-registering
|
||||||
|
-- Not only that, but the decorations also need to be wiped and re-registered - it appears they keep
|
||||||
|
-- track of the biome they belong to via an internal ID that gets changed when the biomes
|
||||||
|
-- are re-registered, resulting in them being left assigned to the wrong biomes.
|
||||||
|
function subterrane:override_biome(biome_def)
|
||||||
|
local registered_biomes_copy = {}
|
||||||
|
for old_biome_key, old_biome_def in pairs(minetest.registered_biomes) do
|
||||||
|
registered_biomes_copy[old_biome_key] = old_biome_def
|
||||||
|
end
|
||||||
|
local registered_decorations_copy = {}
|
||||||
|
for old_decoration_key, old_decoration_def in pairs(minetest.registered_decorations) do
|
||||||
|
registered_decorations_copy[old_decoration_key] = old_decoration_def
|
||||||
|
end
|
||||||
|
|
||||||
|
registered_biomes_copy[biome_def.name] = biome_def
|
||||||
|
|
||||||
|
minetest.clear_registered_decorations()
|
||||||
|
minetest.clear_registered_biomes()
|
||||||
|
for biome_key, new_biome_def in pairs(registered_biomes_copy) do
|
||||||
|
minetest.register_biome(new_biome_def)
|
||||||
|
end
|
||||||
|
for decoration_key, new_decoration_def in pairs(registered_decorations_copy) do
|
||||||
|
minetest.register_decoration(new_decoration_def)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
279
init.lua
Normal file
279
init.lua
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
-- caverealms v.0.8 by HeroOfTheWinds
|
||||||
|
-- original cave code modified from paramat's subterrain
|
||||||
|
-- For Minetest 0.4.8 stable
|
||||||
|
-- Depends default
|
||||||
|
-- License: code WTFPL
|
||||||
|
|
||||||
|
subterrane = {} --create a container for functions and constants
|
||||||
|
|
||||||
|
-- set subterrane.mitigate_lava to true to attempt to mitigate lava spilling into the caves
|
||||||
|
-- set subterrane.get_param2_data to true to make this mod read and set param2 data (shaves a few milliseconds off when you don't, so mods that don't make use of this should leave this unset)
|
||||||
|
|
||||||
|
--grab a shorthand for the filepath of the mod
|
||||||
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
--load companion lua files
|
||||||
|
dofile(modpath.."/nodes.lua")
|
||||||
|
dofile(modpath.."/functions.lua") --function definitions
|
||||||
|
dofile(modpath.."/features.lua")
|
||||||
|
dofile(modpath.."/player_spawn.lua")
|
||||||
|
|
||||||
|
local c_lava = minetest.get_content_id("default:lava_source")
|
||||||
|
--local c_lava_flowing = minetest.get_content_id("default:lava_flowing")
|
||||||
|
local c_obsidian = minetest.get_content_id("default:obsidian")
|
||||||
|
local c_stone = minetest.get_content_id("default:stone")
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
|
subterrane.default_perlin_cave = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=256, y=256, z=256},
|
||||||
|
seed = -400000000089,
|
||||||
|
octaves = 3,
|
||||||
|
persist = 0.67
|
||||||
|
}
|
||||||
|
|
||||||
|
subterrane.default_perlin_wave = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=512, y=256, z=512}, -- squashed 2:1
|
||||||
|
seed = 59033,
|
||||||
|
octaves = 6,
|
||||||
|
persist = 0.63
|
||||||
|
}
|
||||||
|
|
||||||
|
local data = {}
|
||||||
|
local data_param2 = {}
|
||||||
|
|
||||||
|
--{
|
||||||
|
-- minimum_depth = -- required, the highest elevation this cave layer will be generated in.
|
||||||
|
-- maximum_depth = -- required, the lowest elevation this cave layer will be generated in.
|
||||||
|
-- cave_threshold = -- optional, Cave threshold. Defaults to 0.5. 1 = small rare caves, 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume
|
||||||
|
-- boundary_blend_range = -- optional, range near ymin and ymax over which caves diminish to nothing. Defaults to 128.
|
||||||
|
-- perlin_cave = -- optional, a 3D perlin noise definition table to define the shape of the caves
|
||||||
|
-- perlin_wave = -- optional, a 3D perlin noise definition table that's averaged with the cave noise to add floor strata (squash its spread on the y axis relative to perlin_cave to accomplish this)
|
||||||
|
--}
|
||||||
|
|
||||||
|
function subterrane:register_cave_layer(cave_layer_def)
|
||||||
|
|
||||||
|
local YMIN = cave_layer_def.maximum_depth
|
||||||
|
local YMAX = cave_layer_def.minimum_depth
|
||||||
|
local BLEND = math.min(cave_layer_def.boundary_blend_range or 128, (YMAX-YMIN)/2)
|
||||||
|
local TCAVE = cave_layer_def.cave_threshold or 0.5
|
||||||
|
|
||||||
|
-- 3D noise for cave
|
||||||
|
local np_cave = cave_layer_def.perlin_cave or subterrane.default_perlin_cave
|
||||||
|
-- 3D noise for wave
|
||||||
|
local np_wave = cave_layer_def.perlin_wave or subterrane.default_perlin_wave
|
||||||
|
|
||||||
|
local yblmin = YMIN + BLEND * 1.5
|
||||||
|
local yblmax = YMAX - BLEND * 1.5
|
||||||
|
|
||||||
|
-- noise objects
|
||||||
|
local nobj_cave = nil
|
||||||
|
local nobj_wave = nil
|
||||||
|
|
||||||
|
-- On generated function
|
||||||
|
minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
|
--if out of range of cave definition limits, abort
|
||||||
|
if minp.y > YMAX or maxp.y < YMIN then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create a table of biome ids for use with the biomemap.
|
||||||
|
if not subterrane.biome_ids then
|
||||||
|
subterrane.biome_ids = {}
|
||||||
|
for name, desc in pairs(minetest.registered_biomes) do
|
||||||
|
local i = minetest.get_biome_id(desc.name)
|
||||||
|
subterrane.biome_ids[i] = desc.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--easy reference to commonly used values
|
||||||
|
local t_start = os.clock()
|
||||||
|
local x_max = maxp.x
|
||||||
|
local y_max = maxp.y
|
||||||
|
local z_max = maxp.z
|
||||||
|
local x_min = minp.x
|
||||||
|
local y_min = minp.y
|
||||||
|
local z_min = minp.z
|
||||||
|
|
||||||
|
print ("[subterrane] chunk minp ("..x_min.." "..y_min.." "..z_min..")") --tell people you are generating a chunk
|
||||||
|
|
||||||
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
|
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||||
|
vm:get_data(data)
|
||||||
|
if subterrane.get_param2_data then
|
||||||
|
vm:get_param2_data(data_param2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local biomemap = minetest.get_mapgen_object("biomemap")
|
||||||
|
|
||||||
|
--mandatory values
|
||||||
|
local sidelen = x_max - x_min + 1 --length of a mapblock
|
||||||
|
local chunk_lengths = {x = sidelen, y = sidelen, z = sidelen} --table of chunk edges
|
||||||
|
local chunk_lengths2D = {x = sidelen, y = sidelen, z = 1}
|
||||||
|
local minposxyz = {x = x_min, y = y_min, z = z_min} --bottom corner
|
||||||
|
local minposxz = {x = x_min, y = z_min} --2D bottom corner
|
||||||
|
|
||||||
|
nobj_cave = nobj_cave or minetest.get_perlin_map(np_cave, chunk_lengths)
|
||||||
|
nobj_wave = nobj_wave or minetest.get_perlin_map(np_wave, chunk_lengths)
|
||||||
|
|
||||||
|
local nvals_cave = nobj_cave:get3dMap_flat(minposxyz) --cave noise for structure
|
||||||
|
local nvals_wave = nobj_wave:get3dMap_flat(minposxyz) --wavy structure of cavern ceilings and floors
|
||||||
|
|
||||||
|
local index_3d = 1 --3D node index
|
||||||
|
local index_2d = 1 --2D node index
|
||||||
|
|
||||||
|
for z = z_min, z_max do -- for each xy plane progressing northwards
|
||||||
|
--structure loop, hollows out the cavern
|
||||||
|
for y = y_min, y_max do -- for each x row progressing upwards
|
||||||
|
local tcave --declare variable
|
||||||
|
--determine the overall cave threshold
|
||||||
|
if y < yblmin then
|
||||||
|
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||||
|
elseif y > yblmax then
|
||||||
|
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||||
|
else
|
||||||
|
tcave = TCAVE
|
||||||
|
end
|
||||||
|
|
||||||
|
local vi = area:index(x_min, y, z) --current node index
|
||||||
|
for x = x_min, x_max do -- for each node do
|
||||||
|
|
||||||
|
local biome_name = subterrane.biome_ids[biomemap[index_2d]]
|
||||||
|
local biome = minetest.registered_biomes[biome_name]
|
||||||
|
|
||||||
|
local fill_node = c_air
|
||||||
|
if biome and biome._subterrane_fill_node then
|
||||||
|
fill_node = biome._subterrane_fill_node
|
||||||
|
end
|
||||||
|
|
||||||
|
if (nvals_cave[index_3d] + nvals_wave[index_3d])/2 > tcave then --if node falls within cave threshold
|
||||||
|
data[vi] = fill_node --hollow it out to make the cave
|
||||||
|
elseif biome and biome._subterrane_cave_fill_node and data[vi] == c_air then
|
||||||
|
data[vi] = biome._subterrane_cave_fill_node
|
||||||
|
end
|
||||||
|
|
||||||
|
if biome and biome._subterrane_mitigate_lava and (nvals_cave[index_3d] + nvals_wave[index_3d])/2 > tcave - 0.1 then -- Eliminate nearby lava to keep it from spilling in
|
||||||
|
if data[vi] == c_lava then -- or data[vi] == c_lava_flowing then
|
||||||
|
data[vi] = c_obsidian
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--increment indices
|
||||||
|
index_3d = index_3d + 1
|
||||||
|
index_2d = index_2d + 1
|
||||||
|
vi = vi + 1
|
||||||
|
end
|
||||||
|
index_2d = index_2d - sidelen --shift the 2D index back
|
||||||
|
end
|
||||||
|
index_2d = index_2d + sidelen --shift the 2D index up a layer
|
||||||
|
end
|
||||||
|
|
||||||
|
local index_3d = 1 --3D node index
|
||||||
|
local index_2d = 1 --2D node index
|
||||||
|
|
||||||
|
for z = z_min, z_max do -- for each xy plane progressing northwards
|
||||||
|
|
||||||
|
--decoration loop, places nodes on floor and ceiling
|
||||||
|
for y = y_min, y_max do -- for each x row progressing upwards
|
||||||
|
local tcave --same as above
|
||||||
|
if y < yblmin then
|
||||||
|
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||||
|
elseif y > yblmax then
|
||||||
|
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||||
|
else
|
||||||
|
tcave = TCAVE
|
||||||
|
end
|
||||||
|
local vi = area:index(x_min, y, z)
|
||||||
|
for x = x_min, x_max do -- for each node do
|
||||||
|
|
||||||
|
local biome_name = subterrane.biome_ids[biomemap[index_2d]]
|
||||||
|
local biome = minetest.registered_biomes[biome_name]
|
||||||
|
local fill_node = c_air
|
||||||
|
local cave_fill_node = c_air
|
||||||
|
|
||||||
|
if biome then
|
||||||
|
-- only check nodes near the edges of caverns
|
||||||
|
if math.floor(((nvals_cave[index_3d] + nvals_wave[index_3d])/2)*50) == math.floor(tcave*50) then
|
||||||
|
if biome._subterrane_fill_node then
|
||||||
|
fill_node = biome._subterrane_fill_node
|
||||||
|
end
|
||||||
|
--ceiling
|
||||||
|
local ai = area:index(x,y+1,z) --above index
|
||||||
|
local bi = area:index(x,y-1,z) --below index
|
||||||
|
|
||||||
|
if biome._subterrane_ceiling_decor
|
||||||
|
and data[ai] ~= fill_node
|
||||||
|
and data[vi] == fill_node
|
||||||
|
and y < y_max
|
||||||
|
then --ceiling
|
||||||
|
biome._subterrane_ceiling_decor(area, data, ai, vi, bi, data_param2)
|
||||||
|
end
|
||||||
|
--ground
|
||||||
|
if biome._subterrane_floor_decor
|
||||||
|
and data[bi] ~= fill_node
|
||||||
|
and data[vi] == fill_node
|
||||||
|
and y > y_min
|
||||||
|
then --ground
|
||||||
|
biome._subterrane_floor_decor(area, data, ai, vi, bi, data_param2)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif (biome._subterrane_cave_floor_decor or biome._subterrane_cave_ceiling_decor)
|
||||||
|
and (nvals_cave[index_3d] + nvals_wave[index_3d])/2 <= tcave --if node falls outside cave threshold
|
||||||
|
then
|
||||||
|
-- decorate other "native" caves and tunnels
|
||||||
|
if biome._subterrane_cave_fill_node then
|
||||||
|
cave_fill_node = biome._subterrane_cave_fill_node
|
||||||
|
if data[vi] == c_air then
|
||||||
|
data[vi] = cave_fill_node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local ai = area:index(x,y+1,z) --above index
|
||||||
|
local bi = area:index(x,y-1,z) --below index
|
||||||
|
|
||||||
|
if biome._subterrane_cave_ceiling_decor
|
||||||
|
and data[ai] ~= cave_fill_node
|
||||||
|
and data[vi] == cave_fill_node
|
||||||
|
and y < y_max
|
||||||
|
then --ceiling
|
||||||
|
biome._subterrane_cave_ceiling_decor(area, data, ai, vi, bi, data_param2)
|
||||||
|
end
|
||||||
|
--ground
|
||||||
|
if biome._subterrane_cave_floor_decor
|
||||||
|
and data[bi] ~= cave_fill_node
|
||||||
|
and data[vi] == cave_fill_node
|
||||||
|
and y > y_min
|
||||||
|
then --ground
|
||||||
|
biome._subterrane_cave_floor_decor(area, data, ai, vi, bi, data_param2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
index_3d = index_3d + 1
|
||||||
|
index_2d = index_2d + 1
|
||||||
|
vi = vi + 1
|
||||||
|
end
|
||||||
|
index_2d = index_2d - sidelen --shift the 2D index back
|
||||||
|
end
|
||||||
|
index_2d = index_2d + sidelen --shift the 2D index up a layer
|
||||||
|
end
|
||||||
|
|
||||||
|
--send data back to voxelmanip
|
||||||
|
vm:set_data(data)
|
||||||
|
if subterrane.get_param2_data then
|
||||||
|
vm:set_param2_data(data_param2)
|
||||||
|
end
|
||||||
|
--calc lighting
|
||||||
|
vm:set_lighting({day = 0, night = 0})
|
||||||
|
vm:calc_lighting()
|
||||||
|
--write it to world
|
||||||
|
vm:write_to_map(data)
|
||||||
|
|
||||||
|
local chunk_generation_time = math.ceil((os.clock() - t_start) * 1000) --grab how long it took
|
||||||
|
print ("[subterrane] "..chunk_generation_time.." ms") --tell people how long
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
print("[Subterrane] loaded!")
|
45
intllib.lua
Normal file
45
intllib.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
-- Fallback functions for when `intllib` is not installed.
|
||||||
|
-- Code released under Unlicense <http://unlicense.org>.
|
||||||
|
|
||||||
|
-- Get the latest version of this file at:
|
||||||
|
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||||
|
|
||||||
|
local function format(str, ...)
|
||||||
|
local args = { ... }
|
||||||
|
local function repl(escape, open, num, close)
|
||||||
|
if escape == "" then
|
||||||
|
local replacement = tostring(args[tonumber(num)])
|
||||||
|
if open == "" then
|
||||||
|
replacement = replacement..close
|
||||||
|
end
|
||||||
|
return replacement
|
||||||
|
else
|
||||||
|
return "@"..open..num..close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||||
|
end
|
||||||
|
|
||||||
|
local gettext, ngettext
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
if intllib.make_gettext_pair then
|
||||||
|
-- New method using gettext.
|
||||||
|
gettext, ngettext = intllib.make_gettext_pair()
|
||||||
|
else
|
||||||
|
-- Old method using text files.
|
||||||
|
gettext = intllib.Getter()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fill in missing functions.
|
||||||
|
|
||||||
|
gettext = gettext or function(msgid, ...)
|
||||||
|
return format(msgid, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||||
|
return format(n==1 and msgid or msgid_plural, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return gettext, ngettext
|
40
locale/template.pot
Normal file
40
locale/template.pot
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the PACKAGE package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-03-19 15:55-0600\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:64
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:85
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:106
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:127
|
||||||
|
msgid "Dry Dripstone"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:148
|
||||||
|
msgid "Dry Flowstone"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:160
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:181
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:202
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:223
|
||||||
|
msgid "Wet Dripstone"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: C:\Users\Bryan\Downloads\minetest-0.4.15-win64\mods\minetest-caverealms\subterrane\nodes.lua:244
|
||||||
|
msgid "Wet Flowstone"
|
||||||
|
msgstr ""
|
6
locale/update.bat
Normal file
6
locale/update.bat
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
|
||||||
|
cd ..
|
||||||
|
set LIST=
|
||||||
|
for /r %%X in (*.lua) do set LIST=!LIST! %%X
|
||||||
|
..\intllib\tools\xgettext.bat %LIST%
|
249
nodes.lua
Normal file
249
nodes.lua
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
-- internationalization boilerplate
|
||||||
|
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
local S, NS = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
local x_disp = 0.125
|
||||||
|
local z_disp = 0.125
|
||||||
|
|
||||||
|
|
||||||
|
local stal_on_place = function(itemstack, placer, pointed_thing, itemname)
|
||||||
|
local pt = pointed_thing
|
||||||
|
-- check if pointing at a node
|
||||||
|
if not pt then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
if pt.type ~= "node" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local under = minetest.get_node(pt.under)
|
||||||
|
local above = minetest.get_node(pt.above)
|
||||||
|
|
||||||
|
if minetest.is_protected(pt.under, placer:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pt.under, placer:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if minetest.is_protected(pt.above, placer:get_player_name()) then
|
||||||
|
minetest.record_protection_violation(pt.above, placer:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- return if any of the nodes is not registered
|
||||||
|
if not minetest.registered_nodes[under.name] then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
if not minetest.registered_nodes[above.name] then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local new_param2
|
||||||
|
-- check if pointing at the top or bottom of an existing stalactite
|
||||||
|
if (pt.above.y == pt.under.y - 1 or pt.above.y == pt.under.y + 1)
|
||||||
|
and minetest.get_item_group(under.name, "subterrane_stal_align") ~= 0
|
||||||
|
then
|
||||||
|
new_param2 = under.param2
|
||||||
|
else
|
||||||
|
new_param2 = math.random(0,3)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check if you can replace the node above the pointed node
|
||||||
|
if not minetest.registered_nodes[above.name].buildable_to then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add the node and remove 1 item from the itemstack
|
||||||
|
minetest.add_node(pt.above, {name = itemname, param2 = new_param2})
|
||||||
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:dry_stal_1", {
|
||||||
|
description = S("Dry Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, fall_damage_add_percent=100, flow_through=1,},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.0625+x_disp, -0.5, -0.0625+z_disp, 0.0625+x_disp, 0.5, 0.0625+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_1")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:dry_stal_2", {
|
||||||
|
description = S("Dry Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, fall_damage_add_percent=50, flow_through=1,},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.125+x_disp, -0.5, -0.125+z_disp, 0.125+x_disp, 0.5, 0.125+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_2")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:dry_stal_3", {
|
||||||
|
description = S("Dry Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, flow_through=1,},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.25+x_disp, -0.5, -0.25+z_disp, 0.25+x_disp, 0.5, 0.25+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_3")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:dry_stal_4", {
|
||||||
|
description = S("Dry Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, flow_through=1,},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.375+x_disp, -0.5, -0.375+z_disp, 0.375+x_disp, 0.5, 0.375+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_4")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:dry_flowstone", {
|
||||||
|
description = S("Dry Flowstone"),
|
||||||
|
tiles = {"default_stone.png^[brighten"},
|
||||||
|
groups = {cracky = 3, stone = 1},
|
||||||
|
drop = 'default:cobble',
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:wet_stal_1", {
|
||||||
|
description = S("Wet Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten^subterrane_dripstone_streaks.png",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, fall_damage_add_percent=100, subterrane_wet_dripstone = 1, flow_through=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.0625+x_disp, -0.5, -0.0625+z_disp, 0.0625+x_disp, 0.5, 0.0625+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_1")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:wet_stal_2", {
|
||||||
|
description = S("Wet Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten^subterrane_dripstone_streaks.png",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, fall_damage_add_percent=50, subterrane_wet_dripstone = 1, flow_through=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.125+x_disp, -0.5, -0.125+z_disp, 0.125+x_disp, 0.5, 0.125+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_2")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:wet_stal_3", {
|
||||||
|
description = S("Wet Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten^subterrane_dripstone_streaks.png",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, subterrane_wet_dripstone = 1, flow_through=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.25+x_disp, -0.5, -0.25+z_disp, 0.25+x_disp, 0.5, 0.25+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_3")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:wet_stal_4", {
|
||||||
|
description = S("Wet Dripstone"),
|
||||||
|
tiles = {
|
||||||
|
"default_stone.png^[brighten^subterrane_dripstone_streaks.png",
|
||||||
|
},
|
||||||
|
groups = {cracky = 3, stone = 2, subterrane_stal_align = 1, subterrane_wet_dripstone = 1, flow_through=1},
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.375+x_disp, -0.5, -0.375+z_disp, 0.375+x_disp, 0.5, 0.375+z_disp},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
stal_on_place(itemstack, placer, pointed_thing, "subterrane:dry_stal_4")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("subterrane:wet_flowstone", {
|
||||||
|
description = S("Wet Flowstone"),
|
||||||
|
tiles = {"default_stone.png^[brighten^subterrane_dripstone_streaks.png"},
|
||||||
|
groups = {cracky = 3, stone = 1, subterrane_wet_dripstone = 1},
|
||||||
|
drop = 'default:cobble',
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
})
|
111
player_spawn.lua
Normal file
111
player_spawn.lua
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
local spawned = false
|
||||||
|
|
||||||
|
function subterrane:register_cave_spawn(cave_layer_def, start_depth)
|
||||||
|
local ydepth = start_depth or cave_layer_def.minimum_depth;
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
while spawned ~= true do
|
||||||
|
player:setpos({x=0,y=ydepth,z=0})
|
||||||
|
spawnplayer(cave_layer_def, player, ydepth)
|
||||||
|
ydepth = ydepth - 80
|
||||||
|
if ydepth < cave_layer_def.maximum_depth then
|
||||||
|
ydepth = cave_layer_def.minimum_depth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
while spawned ~= true do
|
||||||
|
player:setpos({x=0,y=ydepth,z=0})
|
||||||
|
spawnplayer(cave_layer_def, player, ydepth)
|
||||||
|
ydepth = ydepth - 80
|
||||||
|
if ydepth < cave_layer_def.maximum_depth then
|
||||||
|
ydepth = cave_layer_def.minimum_depth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Spawn player underground
|
||||||
|
function spawnplayer(cave_layer_def, player, ydepth)
|
||||||
|
|
||||||
|
local YMIN = cave_layer_def.maximum_depth
|
||||||
|
local YMAX = cave_layer_def.minimum_depth
|
||||||
|
local BLEND = math.min(cave_layer_def.boundary_blend_range or 128, (YMIN-YMAX)/2)
|
||||||
|
local TCAVE = cave_layer_def.cave_threshold or 0.5
|
||||||
|
|
||||||
|
-- 3D noise for cave
|
||||||
|
local np_cave = cave_layer_def.perlin_cave or subterrane.default_perlin_cave
|
||||||
|
-- 3D noise for wave
|
||||||
|
local np_wave = cave_layer_def.perlin_wave or subterrane.default_perlin_wave
|
||||||
|
|
||||||
|
local yblmin = YMIN + BLEND * 1.5
|
||||||
|
local yblmax = YMAX - BLEND * 1.5
|
||||||
|
|
||||||
|
local xsp
|
||||||
|
local ysp
|
||||||
|
local zsp
|
||||||
|
|
||||||
|
for chunk = 1, 64 do
|
||||||
|
print ("[subterrane] searching for spawn "..chunk)
|
||||||
|
local x0 = 80 * math.random(-32, 32) - 32
|
||||||
|
local z0 = 80 * math.random(-32, 32) - 32
|
||||||
|
local y0 = ydepth-32
|
||||||
|
local x1 = x0 + 79
|
||||||
|
local z1 = z0 + 79
|
||||||
|
local y1 = ydepth+47
|
||||||
|
|
||||||
|
local sidelen = 80
|
||||||
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
|
local minposxyz = {x=x0, y=y0, z=z0}
|
||||||
|
local minposxz = {x=x0, y=z0}
|
||||||
|
|
||||||
|
local nvals_cave = minetest.get_perlin_map(np_cave, chulens):get3dMap_flat(minposxyz) --cave noise for structure
|
||||||
|
local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get3dMap_flat(minposxyz) --wavy structure of cavern ceilings and floors
|
||||||
|
|
||||||
|
local nixz = 1
|
||||||
|
local nixyz = 1
|
||||||
|
for z = z0, z1 do
|
||||||
|
for y = y0, y1 do
|
||||||
|
for x = x0, x1 do
|
||||||
|
local n_abscave = math.abs(nvals_cave[nixyz])
|
||||||
|
local n_abswave = math.abs(nvals_wave[nixyz])
|
||||||
|
|
||||||
|
local tcave --declare variable
|
||||||
|
--determine the overal cave threshold
|
||||||
|
if y < yblmin then
|
||||||
|
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||||
|
elseif y > yblmax then
|
||||||
|
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||||
|
else
|
||||||
|
tcave = TCAVE
|
||||||
|
end
|
||||||
|
|
||||||
|
--if y >= 1 and density > -0.01 and density < 0 then
|
||||||
|
if (nvals_cave[nixyz] + nvals_wave[nixyz])/2 > tcave + 0.005 and (nvals_cave[nixyz] + nvals_wave[nixyz])/2 < tcave + 0.015 then --if node falls within cave threshold
|
||||||
|
ysp = y + 1
|
||||||
|
xsp = x
|
||||||
|
zsp = z
|
||||||
|
break
|
||||||
|
end
|
||||||
|
nixz = nixz + 1
|
||||||
|
nixyz = nixyz + 1
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
nixz = nixz - 80
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
nixz = nixz + 80
|
||||||
|
end
|
||||||
|
if ysp then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print ("[subterrane] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
||||||
|
player:setpos({x=xsp, y=ysp, z=zsp})
|
||||||
|
spawned = true
|
||||||
|
end
|
BIN
textures/subterrane_dripstone_streaks.png
Normal file
BIN
textures/subterrane_dripstone_streaks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 465 B |
Loading…
x
Reference in New Issue
Block a user