revert to ore-rich mapgen

This commit is contained in:
NatureFreshMilk 2019-12-12 08:25:27 +01:00
parent 06922f387b
commit 27253ca46d
5 changed files with 120 additions and 88 deletions

View File

@ -1,13 +1,15 @@
planet_moon = {
miny = tonumber(minetest.settings:get("planet_moon.miny")) or 5000,
maxy = tonumber(minetest.settings:get("planet_moon.maxy")) or 5280,
maxsolidy = tonumber(minetest.settings:get("planet_moon.maxsolidy")) or 5200
maxsolidy = tonumber(minetest.settings:get("planet_moon.maxsolidy")) or 5200,
ores = {},
min_chance = 1
}
local MP = minetest.get_modpath("planet_moon")
dofile(MP.."/stone.lua")
dofile(MP.."/legacy.lua")
dofile(MP.."/ores.lua")
dofile(MP.."/mapgen.lua")

2
legacy.lua Normal file
View File

@ -0,0 +1,2 @@
minetest.register_alias("planet_moon:radioactive_stone", "default:stone")

View File

@ -14,6 +14,16 @@ local base_params = {
persist = 0.6
}
-- ore params
local ore_params = {
offset = 0,
scale = 1,
spread = {x=128, y=64, z=128},
seed = 3454657,
octaves = 4,
persist = 0.6
}
local c_base = minetest.get_content_id("default:stone")
local c_bedrock
@ -27,6 +37,9 @@ end
local base_perlin
local base_perlin_map = {}
local ore_perlin
local ore_perlin_map = {}
minetest.register_on_generated(function(minp, maxp, seed)
if minp.y < planet_moon.miny or minp.y > planet_moon.maxy then
@ -44,7 +57,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
local map_lengths_xyz = {x=side_length, y=side_length, z=side_length}
base_perlin = base_perlin or minetest.get_perlin_map(base_params, map_lengths_xyz)
ore_perlin = ore_perlin or minetest.get_perlin_map(ore_params, map_lengths_xyz)
base_perlin:get3dMap_flat(minp, base_perlin_map)
ore_perlin:get3dMap_flat(minp, ore_perlin_map)
local i = 1
for z=minp.z,maxp.z do
@ -60,12 +76,27 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- unpopulated node
-- higher elevation = lower chance
local chance = (y-minp.y) / side_length
local chance = (y-minp.y) / side_length
local base_n = base_perlin_map[i]
local ore_n = ore_perlin_map[i]
if is_solid or base_n > chance then
data[index] = c_base
if ore_n < planet_moon.min_chance then
-- basic material
data[index] = c_base
else
-- ore material
data[index] = c_base
for _,ore in pairs(planet_moon.ores) do
if ore_n > ore.chance then
data[index] = ore.id
break
end
end
end
end
end
@ -76,7 +107,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
end --z
vm:set_data(data)
minetest.generate_ores(vm, minp, maxp)
vm:write_to_map()
end)

156
ores.lua
View File

@ -1,85 +1,91 @@
local has_technic_mod = minetest.get_modpath("technic")
local has_vacuum_mod = minetest.get_modpath("vacuum")
local clust_scarcity = 24 * 24 * 10
local clust_num_ores = 27
local clust_size = 10
local register_ore = function(def)
table.insert(planet_moon.ores, def)
planet_moon.min_chance = math.min(def.chance, planet_moon.min_chance)
end
minetest.register_ore({
ore_type = "scatter",
ore = "default:stone_with_copper",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
})
if has_technic_mod then
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_uranium",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
if has_vacuum_mod then
c_vacuum = minetest.get_content_id("vacuum:vacuum")
register_ore({
id = c_vacuum,
chance = 1
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_chromium",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_zinc",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_lead",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
})
minetest.register_ore({
ore_type = "scatter",
ore = "technic:mineral_sulfur",
wherein = "default:stone",
clust_scarcity = clust_scarcity,
clust_num_ores = clust_num_ores,
clust_size = clust_size,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
else
register_ore({
id = minetest.get_content_id("air"),
chance = 1
})
end
minetest.register_ore({
ore_type = "scatter",
ore = "planet_moon:radioactive_stone",
wherein = "default:stone",
clust_scarcity = 8 * 8 * 8,
clust_num_ores = 9,
clust_size = 3,
y_max = planet_moon.maxy,
y_min = planet_moon.miny,
register_ore({
id = minetest.get_content_id("default:stone_with_diamond"),
chance = 0.998
})
register_ore({
id = minetest.get_content_id("default:stone_with_mese"),
chance = 0.995
})
register_ore({
id = minetest.get_content_id("default:stone_with_gold"),
chance = 0.99
})
register_ore({
id = minetest.get_content_id("default:stone_with_copper"),
chance = 0.98
})
register_ore({
id = minetest.get_content_id("default:stone_with_iron"),
chance = 0.9
})
register_ore({
id = minetest.get_content_id("default:stone_with_coal"),
chance = 0.8
})
register_ore({
id = minetest.get_content_id("default:ice"),
chance = 0.45
})
if has_technic_mod then
register_ore({
id = minetest.get_content_id("technic:mineral_uranium"),
chance = 0.95
})
register_ore({
id = minetest.get_content_id("technic:mineral_chromium"),
chance = 0.82
})
register_ore({
id = minetest.get_content_id("technic:mineral_zinc"),
chance = 0.75
})
register_ore({
id = minetest.get_content_id("technic:mineral_lead"),
chance = 0.7
})
register_ore({
id = minetest.get_content_id("technic:mineral_sulfur"),
chance = 0.6
})
end
-- sort ores
table.sort(planet_moon.ores, function(a,b)
return b.chance < a.chance
end)

View File

@ -1,8 +0,0 @@
minetest.register_node("planet_moon:radioactive_stone", {
description = "Stone (radioactive)",
tiles = {"default_stone.png^[colorize:#000055:100"},
groups = {cracky = 3, stone = 1, radioactive = 4},
drop = 'default:cobble',
sounds = default.node_sound_stone_defaults(),
})