mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2025-01-11 10:40:26 +01:00
bunch of work on mineclone ores, moved main config into df_dependencies
This commit is contained in:
parent
79d4b95c2b
commit
e1eb163386
@ -1,11 +1,10 @@
|
||||
df_caverns = {}
|
||||
df_caverns.config = df_dependencies.config
|
||||
|
||||
--grab a shorthand for the filepath of the mod
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
--load companion lua files
|
||||
dofile(modpath.."/config.lua")
|
||||
|
||||
dofile(modpath.."/node_ids.lua")
|
||||
|
||||
dofile(modpath.."/shared.lua")
|
||||
|
@ -1,6 +1,8 @@
|
||||
local CONFIG_FILE_PREFIX = "dfcaverns_"
|
||||
|
||||
df_caverns.config = {}
|
||||
local config = {}
|
||||
df_dependencies.config = config
|
||||
|
||||
|
||||
local print_settingtypes = false
|
||||
|
||||
@ -16,7 +18,7 @@ local function setting(stype, name, default, description)
|
||||
if value == nil then
|
||||
value = default
|
||||
end
|
||||
df_caverns.config[name] = value
|
||||
config[name] = value
|
||||
|
||||
if print_settingtypes then
|
||||
minetest.debug(CONFIG_FILE_PREFIX..name.." ("..description..") "..stype.." "..tostring(default))
|
||||
@ -38,14 +40,14 @@ setting("int", "level3_min", -2112, "Upper limit of the sunless seas")
|
||||
setting("int", "sunless_sea_min", -2512, "Lower limit of the sunless seas")
|
||||
|
||||
setting("bool", "enable_oil_sea", true, "Enable oil sea")
|
||||
df_caverns.config.enable_oil_sea = df_caverns.config.enable_oil_sea and minetest.get_modpath("oil") ~= nil
|
||||
config.enable_oil_sea = config.enable_oil_sea and minetest.get_modpath("oil") ~= nil
|
||||
setting("int", "oil_sea_level", -2700, "Oil sea level")
|
||||
|
||||
setting("bool", "enable_lava_sea", true, "Enable magma sea")
|
||||
setting("int", "lava_sea_level", -2900, "Lava sea level")
|
||||
|
||||
setting("bool", "enable_underworld", true, "Enable underworld")
|
||||
df_caverns.config.enable_underworld = df_caverns.config.enable_underworld and minetest.get_modpath("df_underworld_items") ~= nil
|
||||
config.enable_underworld = config.enable_underworld and minetest.get_modpath("df_underworld_items") ~= nil
|
||||
setting("int", "underworld_level", -3200, "Underworld level")
|
||||
setting("int", "underworld_glowing_pit_mapblocks", 8, "Average pit spacing measured in mapblocks")
|
||||
|
@ -31,6 +31,7 @@ df_dependencies.select_optional = function(def)
|
||||
return ret
|
||||
end
|
||||
|
||||
dofile(modpath.."/config.lua")
|
||||
dofile(modpath.."/sounds.lua")
|
||||
dofile(modpath.."/helper_functions.lua")
|
||||
dofile(modpath.."/nodes.lua")
|
||||
|
@ -1,20 +1,31 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local prefix = "dfcaverns_"
|
||||
-- NOTE: These defaults are from df_caverns' config. Update them if those change.
|
||||
local function deep_copy(table_in)
|
||||
local table_out = {}
|
||||
for index, value in pairs(table_in) do
|
||||
if type(value) == "table" then
|
||||
table_out[index] = deep_copy(value)
|
||||
else
|
||||
table_out[index] = value
|
||||
end
|
||||
end
|
||||
return table_out
|
||||
end
|
||||
|
||||
local lowest_elevation = tonumber(minetest.settings:get(prefix.."sunless_sea_min")) or -2512
|
||||
if minetest.settings:get_bool(prefix.."enable_oil_sea", true) then
|
||||
lowest_elevation = (tonumber(minetest.settings:get(prefix.."oil_sea_level")) or -2700)
|
||||
local config = df_dependencies.config
|
||||
|
||||
local lowest_elevation = config.sunless_sea_min
|
||||
if config.enable_oil_sea then
|
||||
lowest_elevation = config.oil_sea_level
|
||||
end
|
||||
if minetest.settings:get_bool(prefix.."enable_lava_sea", true) then
|
||||
lowest_elevation = (tonumber(minetest.settings:get(prefix.."lava_sea_level")) or -2900)
|
||||
if config.enable_lava_sea then
|
||||
lowest_elevation = config.lava_sea_level
|
||||
end
|
||||
if minetest.settings:get_bool(prefix.."enable_underworld", true) then
|
||||
lowest_elevation = (tonumber(minetest.settings:get(prefix.."underworld_level")) or -3200)
|
||||
if config.enable_underworld then
|
||||
lowest_elevation = config.underworld_level
|
||||
end
|
||||
if minetest.settings:get_bool(prefix.."enable_primordial", true) then
|
||||
lowest_elevation = (tonumber(minetest.settings:get(prefix.."primordial_min")) or -4032)
|
||||
if config.enable_primordial then
|
||||
lowest_elevation = config.primordial_min
|
||||
end
|
||||
lowest_elevation = lowest_elevation - 193 -- add a little buffer space
|
||||
|
||||
@ -26,19 +37,162 @@ df_dependencies.mods_required.mcl_mapgen = true
|
||||
|
||||
local old_overworld_min
|
||||
|
||||
local extend_ores = function()
|
||||
local ores_registered = {}
|
||||
for key, val in pairs(minetest.registered_ores) do
|
||||
ores_registered[val.ore] = true
|
||||
end
|
||||
|
||||
local wherein_stonelike = {"mcl_core:stone"}
|
||||
local localseed = 12345
|
||||
|
||||
local stone_blobs = {
|
||||
wherein = wherein_stonelike,
|
||||
clust_scarcity = 1000,
|
||||
clust_size = 7,
|
||||
y_min = lowest_elevation,
|
||||
y_max = old_overworld_min,
|
||||
ore_type = "blob",
|
||||
clust_num_ores = 58,
|
||||
noise_params = {
|
||||
octaves = 3,
|
||||
seed = 12345,
|
||||
lacunarity = 2,
|
||||
spread = {
|
||||
y = 250,
|
||||
x = 250,
|
||||
z = 250
|
||||
},
|
||||
persist = 0.6,
|
||||
flags = "defaults",
|
||||
offset = 0,
|
||||
scale = 1
|
||||
},
|
||||
}
|
||||
|
||||
local register_blob = function(ore, cluster_size, cluster_scarcity_cuberoot, ymin, ymax)
|
||||
localseed = localseed + 1 -- increment this every time it's called to ensure different distributions
|
||||
local blob_copy = deep_copy(stone_blobs)
|
||||
blob_copy.ore = ore
|
||||
blob_copy.clust_num_ores = cluster_size
|
||||
blob_copy.seed = localseed
|
||||
blob_copy.cluster_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
|
||||
blob_copy.y_min = ymin or stone_blobs.y_min
|
||||
blob_copy.y_max = ymax or stone_blobs.y_max
|
||||
end
|
||||
|
||||
local scattered_ore = {
|
||||
wherein = wherein_stonelike,
|
||||
ore_type = "scatter",
|
||||
ore = "mcl_core:stone_with_coal",
|
||||
clust_scarcity = 525*3,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_min = lowest_elevation,
|
||||
y_max = old_overworld_min,
|
||||
noise_params = deep_copy(stone_blobs.noise_params), -- since there's so much volume to scatter ore in, using noise to make some regions "rich" and others "poor" for variety
|
||||
noise_threshold= 0,
|
||||
}
|
||||
|
||||
local register_scattered_internal = function(ore, cluster_size, cluster_scarcity_cuberoot, threshold, ymin, ymax)
|
||||
local scattered_copy = deep_copy(scattered_ore)
|
||||
scattered_copy.ore = ore
|
||||
scattered_copy.cluster_size = cluster_size*cluster_size*cluster_size
|
||||
scattered_copy.clust_num_ores = math.ceil(scattered_copy.cluster_size/3)
|
||||
scattered_copy.seed = localseed
|
||||
scattered_copy.cluster_scarcity = cluster_scarcity_cuberoot*cluster_scarcity_cuberoot*cluster_scarcity_cuberoot
|
||||
scattered_copy.threshold = threshold
|
||||
scattered_copy.y_min = ymin or scattered_ore.y_min
|
||||
scattered_copy.y_max = ymax or scattered_ore.y_max
|
||||
end
|
||||
local register_scattered = function(ore, cluster_size, cluster_scarcity_cuberoot, ymin, ymax)
|
||||
assert(not (ymin and ymax) or ymin < ymax, "Elevation parameter error for register_scattered")
|
||||
localseed = localseed + 1 -- increment this every time it's called to ensure different distributions
|
||||
-- same seed makes the noise patterns overlap.
|
||||
-- one produces widespread smaller clusters, other produces larger clusters at the peaks of the noise in addition to the smaller ones
|
||||
register_scattered_internal(ore, cluster_size, cluster_scarcity_cuberoot, 0, ymin)
|
||||
register_scattered_internal(ore, cluster_size*2, cluster_scarcity_cuberoot, 0.25, ymax)
|
||||
end
|
||||
|
||||
if ores_registered["mcl_core:diorite"] then
|
||||
register_blob("mcl_core:diorite", 58, 10)
|
||||
register_blob("mcl_core:diorite", 33, 15)
|
||||
table.insert(wherein_stonelike, "mcl_core:diorite")
|
||||
end
|
||||
if ores_registered["mcl_core:andesite"] then
|
||||
register_blob("mcl_core:andesite", 58, 10)
|
||||
register_blob("mcl_core:andesite", 33, 15)
|
||||
table.insert(wherein_stonelike, "mcl_core:andesite")
|
||||
end
|
||||
if ores_registered["mcl_core:granite"] then
|
||||
register_blob("mcl_core:granite", 58, 10)
|
||||
register_blob("mcl_core:granite", 33, 15)
|
||||
table.insert(wherein_stonelike, "mcl_core:granite")
|
||||
end
|
||||
if ores_registered["mcl_core:dirt"] then
|
||||
register_blob("mcl_core:dirt", 33, 15)
|
||||
end
|
||||
if ores_registered["mcl_core:gravel"] then
|
||||
register_blob("mcl_core:gravel", 33, 14)
|
||||
end
|
||||
|
||||
if ores_registered["mcl_core:stone_with_iron"] then
|
||||
register_scattered("mcl_core:stone_with_iron", 3, 12)
|
||||
end
|
||||
if ores_registered["mcl_core:stone_with_coal"] then
|
||||
register_scattered("mcl_core:stone_with_coal", 3, 12)
|
||||
if config.enable_oil_sea then
|
||||
register_blob("mcl_core:stone_with_coal", 80, 10, config.oil_sea_level-200, config.oil_sea_level+200) -- tons of coal in the oil sea
|
||||
end
|
||||
end
|
||||
|
||||
if ores_registered["mcl_core:stone_with_lapis"] then
|
||||
register_scattered("mcl_core:stone_with_lapis", 3, 25, config.sunless_sea_min, config.level3_min) -- Lapis is an ocean gem, I decided
|
||||
if config.enable_primordial then
|
||||
register_scattered("mcl_core:stone_with_lapis", 3, 25, config.primordial_min, config.primordial_max)
|
||||
end
|
||||
end
|
||||
|
||||
if ores_registered["mcl_core:stone_with_redstone"] then
|
||||
register_scattered("mcl_core:stone_with_redstone", 3, 15, config.level3_min, config.level2_min) -- Level 3 is the most magical, scatter redstone there
|
||||
if config.enable_lava_sea then
|
||||
register_scattered("mcl_core:stone_with_redstone", 4, 15, config.lava_sea_level-200, config.lava_sea_level+100) -- and of course plenty of redstone in the lava sea
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--"mcl_core:stone_with_diamond"
|
||||
if ores_registered["mcl_core:stone_with_gold"] then
|
||||
register_scattered("mcl_core:stone_with_gold", 2, 18)
|
||||
end
|
||||
--"mcl_copper:stone_with_copper"
|
||||
|
||||
-- more blobs
|
||||
--"mcl_deepslate:deepslate"
|
||||
--"mcl_deepslate:tuff"
|
||||
|
||||
-- apparently very rare
|
||||
--"mcl_deepslate:deepslate_with_emerald"
|
||||
--"mcl_core:stone_with_emerald"
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if minetest.get_modpath("mcl_init") then -- Mineclone 2
|
||||
|
||||
old_overworld_min = mcl_vars.mg_overworld_min -- remember this for weather control
|
||||
|
||||
mcl_vars.mg_overworld_min = lowest_elevation
|
||||
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
|
||||
mcl_vars.mg_lava_overworld_max = mcl_vars.mg_overworld_min + 10
|
||||
mcl_vars.mg_end_max = mcl_vars.mg_overworld_min - 2000
|
||||
|
||||
-- Important note. This doesn't change the values for the various ores and mobs and biomes and whatnot that have already been registered.
|
||||
-- TODO
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/ores.lua")
|
||||
|
||||
if minetest.settings:get_bool("mcl_generate_ores", true) then
|
||||
extend_ores()
|
||||
end
|
||||
|
||||
df_dependencies.mods_required.mcl_structures = true
|
||||
-- never mind - add dependency on mcl_strongholds and these will get generated before overworld_min gets changed.
|
||||
--if minetest.get_modpath("mcl_structures") and minetest.get_modpath("mcl_strongholds") then
|
||||
-- local elevation_delta = old_overworld_min - lowest_elevation
|
||||
|
@ -1,17 +1,13 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local required_nodes = {}
|
||||
local function select_required(...)
|
||||
local newdef = {}
|
||||
for _, node in pairs({...}) do
|
||||
newdef[string.match(node, "(.-):")] = node
|
||||
end
|
||||
local ret = df_dependencies.select_required(newdef)
|
||||
minetest.after(0, function()
|
||||
-- "after" needs to be used here because some of these nodes actually get registered in DF Caverns itself
|
||||
-- stair nodes, for example, depend on the stairs mod but get registered from here. Kind of weird but
|
||||
-- one goes to war with the mods one has.
|
||||
assert(minetest.registered_items[ret] ~= nil, "Node " .. ret .. " was returned by a selection call but is not registered.")
|
||||
end)
|
||||
table.insert(required_nodes, ret)
|
||||
return ret
|
||||
end
|
||||
|
||||
@ -21,14 +17,26 @@ local function select_optional(...)
|
||||
newdef[string.match(node, "(.-):")] = node
|
||||
end
|
||||
local ret = df_dependencies.select_optional(newdef)
|
||||
if ret ~= nil then
|
||||
minetest.after(0, function()
|
||||
assert(minetest.registered_items[ret] ~= nil, "Node " .. ret .. " was returned by an optional selection call but is not registered.")
|
||||
end)
|
||||
end
|
||||
table.insert(required_nodes, ret)
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
minetest.after(0, function()
|
||||
-- "after" needs to be used here because some of these nodes actually get registered in DF Caverns itself
|
||||
-- stair nodes, for example, depend on the stairs mod but get registered from here. Kind of weird but
|
||||
-- one goes to war with the mods one has.
|
||||
local problem_nodes = {}
|
||||
for _, node_name in pairs(required_nodes) do
|
||||
if minetest.registered_items[node_name] == nil then
|
||||
table.insert(problem_nodes, node_name)
|
||||
end
|
||||
end
|
||||
|
||||
assert(#problem_nodes == 0, "Nodes " .. table.concat(problem_nodes, ", ") .. " were returned by a selection call but are not registered.")
|
||||
end)
|
||||
|
||||
|
||||
df_dependencies.node_name_apple = select_required("default:apple", "mcl_core:apple")
|
||||
df_dependencies.node_name_chest = select_required("default:chest", "mcl_chests:chest")
|
||||
df_dependencies.node_name_coalblock = select_required("default:coalblock", "mcl_core:coalblock")
|
||||
|
@ -1,8 +0,0 @@
|
||||
-- copied from mcl_mapgen_core with tweaked altitudes to cover the added depth
|
||||
|
||||
if minetest.settings:get_bool("mcl_generate_ores", true) then
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
@ -51,6 +51,7 @@ df_mapitems.spawn_castle_coral = function(area, data, vi, iterations)
|
||||
local zstride = area.zstride
|
||||
local ystride = area.ystride
|
||||
while run > 0 do
|
||||
-- TODO should this be checking for not-water instead of stone?
|
||||
if math.random() > 0.95 or data[index] == c_stone or not area:containsi(index) then return end
|
||||
data[index] = c_coral
|
||||
if iterations > 2 then
|
||||
|
Loading…
Reference in New Issue
Block a user