Grass in patches. Add redstone in desert. Simple sandstone strata

This commit is contained in:
paramat 2014-10-26 06:51:26 +00:00
parent bea230e2b8
commit 525cad60ec
3 changed files with 106 additions and 77 deletions

View File

@ -1,4 +1,4 @@
riverdev 0.5.8 by paramat riverdev 0.5.9 by paramat
For latest stable Minetest back to 0.4.8 For latest stable Minetest back to 0.4.8
Depends default Depends default
Licenses: code WTFPL Licenses: code WTFPL

172
init.lua
View File

@ -1,14 +1,17 @@
-- riverdev 0.5.8 by paramat -- riverdev 0.5.9 by paramat
-- For latest stable Minetest and back to 0.4.8 -- For latest stable Minetest and back to 0.4.8
-- Depends default -- Depends default
-- License: code WTFPL -- License: code WTFPL
-- humidity by displacing seamap in wind direction, plus a river influence -- patches of grass
-- redstone in desert
-- simple sandstone strata
-- TODO -- TODO
-- regeneration command: use of mapgen loop function -- regeneration command: use of mapgen loop function
-- coloured stone: desertstone orange sandstone green blue violet -- coloured stone: desertstone orange sandstone green blue violet
-- inclined strata with 3d biomes of coloured stone mixes -- inclined strata with 3d biomes of coloured stone mixes
-- ores in strata -- ores in strata
-- dry long grass to replace dry shrub
-- Parameters -- Parameters
@ -28,7 +31,7 @@ local TRIVER = -0.018 -- River depth
local TRSAND = -0.02 -- Depth of river sand local TRSAND = -0.02 -- Depth of river sand
local TPFLO = 0.02 -- Width of flora clearing around paths local TPFLO = 0.02 -- Width of flora clearing around paths
local TTUN = 0.02 -- Tunnel width local TTUN = 0.02 -- Tunnel width
local TFIS = 0.005 -- Fissure width local TFIS = 0.004 -- Fissure width
local TCAV = 1 -- Cavern threshold local TCAV = 1 -- Cavern threshold
local TMAG = 0.015 -- Magma tunnel width local TMAG = 0.015 -- Magma tunnel width
local TOBS = 0.025 -- Obsidian tube width local TOBS = 0.025 -- Obsidian tube width
@ -36,32 +39,20 @@ local TOBS = 0.025 -- Obsidian tube width
-- 1 / n ^ 3 where n = average distance between ores -- 1 / n ^ 3 where n = average distance between ores
local ORECHA = 1 / 5 ^ 3 -- Ore chance per stone node local ORECHA = 1 / 5 ^ 3 -- Ore chance per stone node
-- 1 / n ^ 2 where n = average distance between features -- 1 / n ^ 2 where n = average distance between features
local BOLCHA = 1 / 127 ^ 2 -- Boulder chance per surfacenode local BOLCHA = 1 / 128 ^ 2 -- Boulder chance per surfacenode
local FLOCHA = 1 / 37 ^ 2 -- Flower ^ local FLOCHA = 1 / 48 ^ 2 -- Flower ^
local JUNCHA = 1 / 4 ^ 2 -- Jungletree ^ local JUNCHA = 1 / 4 ^ 2 -- Jungletree ^
local CACCHA = 1 / 128 ^ 2 -- Cactus ^
local GRACHA = 1 / 2 ^ 2 -- Grasses ^
local APPCHA = 1 / 5 ^ 2 -- Appletree maximum chance per surface node local APPCHA = 1 / 5 ^ 2 -- Appletree maximum chance per surface node
local PINCHA = 1 / 6 ^ 2 -- Pinetree ^ local PINCHA = 1 / 6 ^ 2 -- Pinetree ^
local ACACHA = 1 / 47 ^ 2 -- Acaciatree ^ local ACACHA = 1 / 64 ^ 2 -- Acaciatree ^
local GRACHA = 1 / 4 ^ 2 -- Grasses ^
local CACCHA = 1 / 47 ^ 2 -- Cactus ^
local LOTET = -0.4 -- Low temperature threshold local LOTET = -0.4 -- Low temperature threshold
local HITET = 0.4 -- High ^ local HITET = 0.4 -- High ^
local LOHUT = 0.2 -- Low humidity threshold (abs noise) local LOHUT = 0.2 -- Low humidity threshold (abs noise)
local MIDHUT = 0.4 -- Mid ^
local HIHUT = 0.6 -- High ^ local HIHUT = 0.6 -- High ^
-- 3D noise for highland terrain
local np_terrain = {
offset = 0,
scale = 1,
spread = {x=192, y=192, z=192},
seed = 5900033,
octaves = 4,
persist = 0.67
}
-- 2D noise for mid terrain / river -- 2D noise for mid terrain / river
local np_mid = { local np_mid = {
@ -125,7 +116,7 @@ local np_tree = {
spread = {x=384, y=384, z=384}, spread = {x=384, y=384, z=384},
seed = 133338, seed = 133338,
octaves = 4, octaves = 4,
persist = 0.6 persist = 0.7
} }
-- 2D noise for grasses -- 2D noise for grasses
@ -133,12 +124,23 @@ local np_tree = {
local np_grass = { local np_grass = {
offset = 0, offset = 0,
scale = 1, scale = 1,
spread = {x=192, y=192, z=192}, spread = {x=96, y=96, z=96},
seed = -138, seed = -138,
octaves = 4, octaves = 4,
persist = 0.7 persist = 0.7
} }
-- 3D noise for highland terrain
local np_terrain = {
offset = 0,
scale = 1,
spread = {x=192, y=192, z=192},
seed = 5900033,
octaves = 4,
persist = 0.67
}
-- 3D noises for tunnels -- 3D noises for tunnels
local np_weba = { local np_weba = {
@ -155,11 +157,11 @@ local np_webb = {
scale = 1, scale = 1,
spread = {x=191, y=191, z=191}, spread = {x=191, y=191, z=191},
seed = 33, seed = 33,
octaves = 4, octaves = 3,
persist = 0.4 persist = 0.4
} }
-- 3D noise for magma tunnels -- 3D noises for magma tunnels
local np_webc = { local np_webc = {
offset = 0, offset = 0,
@ -190,15 +192,15 @@ local np_fissure = {
persist = 0.4 persist = 0.4
} }
-- 3D noise for rock strata inclination -- 3D noise for strata layering
local np_strata = { local np_strata = {
offset = 0, offset = 0,
scale = 1, scale = 1,
spread = {x=768, y=768, z=768}, spread = {x=768, y=16, z=768},
seed = 92219, seed = 92219,
octaves = 2, octaves = 4,
persist = 0.6 persist = 1
} }
-- Stuff -- Stuff
@ -206,6 +208,9 @@ local np_strata = {
dofile(minetest.get_modpath("riverdev").."/functions.lua") dofile(minetest.get_modpath("riverdev").."/functions.lua")
dofile(minetest.get_modpath("riverdev").."/nodes.lua") dofile(minetest.get_modpath("riverdev").."/nodes.lua")
local nvals_strata
local stratanoise = false
-- Mapgen functions -- Mapgen functions
local function riverdev_pathbrush(x, y, z, area, data, local function riverdev_pathbrush(x, y, z, area, data,
@ -252,15 +257,11 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
local c_grass5 = minetest.get_content_id("default:grass_5") local c_grass5 = minetest.get_content_id("default:grass_5")
local c_snowblock = minetest.get_content_id("default:snowblock") local c_snowblock = minetest.get_content_id("default:snowblock")
local c_jungrass = minetest.get_content_id("default:junglegrass") local c_jungrass = minetest.get_content_id("default:junglegrass")
local c_dryshrub = minetest.get_content_id("default:dry_shrub")
local c_drygrass = minetest.get_content_id("riverdev:drygrass") local c_drygrass = minetest.get_content_id("riverdev:drygrass")
local c_goldengrass = minetest.get_content_id("riverdev:goldengrass") local c_goldengrass = minetest.get_content_id("riverdev:goldengrass")
local c_icydirt = minetest.get_content_id("riverdev:icydirt") local c_icydirt = minetest.get_content_id("riverdev:icydirt")
if under[si] == 1 then -- tundra if under[si] == 1 then -- tundra
data[viu] = c_icydirt data[viu] = c_icydirt
if math.random() < GRACHA * n_grass then
data[vi] = c_dryshrub
end
elseif under[si] == 2 then -- taiga elseif under[si] == 2 then -- taiga
if math.random() < PINCHA * n_tree if math.random() < PINCHA * n_tree
and n_abspatha > TPFLO and n_abspathb > TPFLO then and n_abspatha > TPFLO and n_abspathb > TPFLO then
@ -271,9 +272,6 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
end end
elseif under[si] == 3 then -- dry grassland elseif under[si] == 3 then -- dry grassland
data[viu] = c_drygrass data[viu] = c_drygrass
if math.random() < GRACHA * n_grass then
data[vi] = c_dryshrub
end
elseif under[si] == 4 then -- forest/grassland elseif under[si] == 4 then -- forest/grassland
if math.random() < BOLCHA if math.random() < BOLCHA
and n_abspatha > TPFLO and n_abspathb > TPFLO then and n_abspatha > TPFLO and n_abspathb > TPFLO then
@ -288,20 +286,20 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
data[viu] = c_grass data[viu] = c_grass
if math.random() < FLOCHA then if math.random() < FLOCHA then
riverdev_flower(data, vi) riverdev_flower(data, vi)
elseif math.random() < GRACHA * n_grass then elseif math.random() < GRACHA and n_grass > 0.6 then
data[vi] = c_grass5 data[vi] = c_grass5
end end
end end
elseif under[si] == 5 then -- desert elseif under[si] == 5 then -- desert
if math.random() < CACCHA * n_grass then if math.random() < CACCHA then
riverdev_cactus(x, y, z, area, data) riverdev_cactus(x, y, z, area, data)
end end
elseif under[si] == 6 then elseif under[si] == 6 then -- savanna
if math.random() < ACACHA * n_tree then if math.random() < ACACHA * n_tree then
riverdev_acaciatree(x, y, z, area, data) riverdev_acaciatree(x, y, z, area, data)
else else
data[viu] = c_drygrass data[viu] = c_drygrass
if math.random() < GRACHA * n_grass then if math.random() < GRACHA and n_grass > 0.6 then
data[vi] = c_goldengrass data[vi] = c_goldengrass
end end
end end
@ -311,7 +309,7 @@ local function riverdev_surface(x, y, z, area, data, y1, vi, viu,
riverdev_jungletree(x, y, z, area, data, y1) riverdev_jungletree(x, y, z, area, data, y1)
else else
data[viu] = c_grass data[viu] = c_grass
if math.random() < GRACHA then if math.random() < GRACHA and n_grass > 0.6 then
data[vi] = c_jungrass data[vi] = c_jungrass
end end
end end
@ -350,6 +348,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_ignore = minetest.get_content_id("ignore") local c_ignore = minetest.get_content_id("ignore")
local c_water = minetest.get_content_id("default:water_source") local c_water = minetest.get_content_id("default:water_source")
local c_sand = minetest.get_content_id("default:sand") local c_sand = minetest.get_content_id("default:sand")
local c_sandstone = minetest.get_content_id("default:sandstone")
local c_wood = minetest.get_content_id("default:junglewood") local c_wood = minetest.get_content_id("default:junglewood")
local c_snowblock = minetest.get_content_id("default:snowblock") local c_snowblock = minetest.get_content_id("default:snowblock")
local c_grass5 = minetest.get_content_id("default:grass_5") local c_grass5 = minetest.get_content_id("default:grass_5")
@ -368,6 +367,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_dirt = minetest.get_content_id("riverdev:dirt") local c_dirt = minetest.get_content_id("riverdev:dirt")
local c_grass = minetest.get_content_id("riverdev:grass") local c_grass = minetest.get_content_id("riverdev:grass")
local c_stone = minetest.get_content_id("riverdev:stone") local c_stone = minetest.get_content_id("riverdev:stone")
local c_redstone = minetest.get_content_id("riverdev:redstone")
local c_path = minetest.get_content_id("riverdev:path") local c_path = minetest.get_content_id("riverdev:path")
local c_freshwater = minetest.get_content_id("riverdev:freshwater") local c_freshwater = minetest.get_content_id("riverdev:freshwater")
local c_mixwater = minetest.get_content_id("riverdev:mixwater") local c_mixwater = minetest.get_content_id("riverdev:mixwater")
@ -389,12 +389,12 @@ minetest.register_on_generated(function(minp, maxp, seed)
local nvals_webb = minetest.get_perlin_map(np_webb, chulensxyz):get3dMap_flat(minposxyz) local nvals_webb = minetest.get_perlin_map(np_webb, chulensxyz):get3dMap_flat(minposxyz)
local nvals_webc = minetest.get_perlin_map(np_webc, chulensxyz):get3dMap_flat(minposxyz) local nvals_webc = minetest.get_perlin_map(np_webc, chulensxyz):get3dMap_flat(minposxyz)
local nvals_webd = minetest.get_perlin_map(np_webd, chulensxyz):get3dMap_flat(minposxyz) local nvals_webd = minetest.get_perlin_map(np_webd, chulensxyz):get3dMap_flat(minposxyz)
local nvals_strata = minetest.get_perlin_map(np_strata, chulensxyz):get3dMap_flat(minposxyz)
local nvals_fissure = minetest.get_perlin_map(np_fissure, chulensxyz):get3dMap_flat(minposxyz) local nvals_fissure = minetest.get_perlin_map(np_fissure, chulensxyz):get3dMap_flat(minposxyz)
local nvals_strata = minetest.get_perlin_map(np_strata, chulensxyz):get3dMap_flat(minposxyz)
local nvals_mid = minetest.get_perlin_map(np_mid, chulensxz):get2dMap_flat(minposxz) local nvals_mid = minetest.get_perlin_map(np_mid, chulensxz):get2dMap_flat(minposxz)
local nvals_base = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat(minposxz) local nvals_base = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat(minposxz)
local nvals_humid = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat({x=x0-1, y=z0-769}) local nvals_humid = minetest.get_perlin_map(np_base, chulensxz):get2dMap_flat({x=x0-1, y=z0+383})
local nvals_patha = minetest.get_perlin_map(np_patha, chulensxz):get2dMap_flat(minposxz) local nvals_patha = minetest.get_perlin_map(np_patha, chulensxz):get2dMap_flat(minposxz)
local nvals_pathb = minetest.get_perlin_map(np_pathb, chulensxz):get2dMap_flat(minposxz) local nvals_pathb = minetest.get_perlin_map(np_pathb, chulensxz):get2dMap_flat(minposxz)
local nvals_temp = minetest.get_perlin_map(np_temp, chulensxz):get2dMap_flat(minposxz) local nvals_temp = minetest.get_perlin_map(np_temp, chulensxz):get2dMap_flat(minposxz)
@ -453,17 +453,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5 n_terrain * n_invbase * n_absmid * n_abspatha ^ 1.5 * n_abspathb ^ 1.5
+ densitymid -- actual surface + densitymid -- actual surface
local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1)
local n_grass = math.abs(nvals_grass[nixz])
local n_strata = nvals_strata[nixyz]
local n_temp = nvals_temp[nixz]
local n_humid = math.abs(nvals_humid[nixz]) - n_absmid * 0.5 + 0.25
local tstone = TSTONE * (1 + grad * 2) local tstone = TSTONE * (1 + grad * 2)
local triver = TRIVER * n_absbase local triver = TRIVER * n_absbase
local trsand = TRSAND * n_absbase local trsand = TRSAND * n_absbase
local wood = densitybase > trsand * 2 and density < 0 local wood = densitybase > trsand * 2 and density < 0
local tobs = TOBS + (density + tstone) local tobs = TOBS + (density + tstone)
local n_strata = nvals_strata[nixyz]
local densitystrata = grad + n_strata * 0.5
local n_temp = nvals_temp[nixz]
local n_humid = math.abs(nvals_humid[nixz]) - n_absmid * 0.5 + 0.25
local n_tree = math.min(math.max(nvals_tree[nixz], 0), 1)
local n_grass = math.min(math.max(nvals_grass[nixz], 0), 1)
if chunkxz and y == y0 - 1 then -- overgeneration, initialise tables if chunkxz and y == y0 - 1 then -- overgeneration, initialise tables
under[si] = 0 under[si] = 0
@ -486,6 +485,29 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
elseif chunkxz and y >= y0 and y <= y1 then -- chunk generation elseif chunkxz and y >= y0 and y <= y1 then -- chunk generation
local biome = 0
if n_temp < LOTET then
if n_humid < LOHUT then -- tundra
biome = 1
else -- taiga
biome = 2
end
elseif n_temp > HITET then
if n_humid < LOHUT then -- desert
biome = 5
elseif n_humid > HIHUT then -- rainforest
biome = 7
else -- savanna
biome = 6
end
else
if n_humid < LOHUT then -- dry grassland
biome = 3
else -- temperate forest / grassland
biome = 4
end
end
if density >= -tstone -- magma/obsidian network if density >= -tstone -- magma/obsidian network
and ((n_abswebc <= TOBS and n_abswebd <= TOBS) and ((n_abswebc <= TOBS and n_abswebd <= TOBS)
or (density < tstone and n_abswebc <= tobs and n_abswebd <= tobs)) then or (density < tstone and n_abswebc <= tobs and n_abswebd <= tobs)) then
@ -503,7 +525,11 @@ minetest.register_on_generated(function(minp, maxp, seed)
elseif density >= tstone and (novoid elseif density >= tstone and (novoid
or (density < tstone * 1.5 or (density < tstone * 1.5
and (y <= YWATER or densitybase >= triver))) then and (y <= YWATER or densitybase >= triver))) then
if math.random() < ORECHA and density > TSTONE then -- ores if n_strata > 0.7 then
data[vi] = c_sandstone -- redstone layer
elseif biome == 5 then
data[vi] = c_redstone -- redstone layer
elseif math.random() < ORECHA and density > TSTONE then -- ores
local osel = math.random(24) local osel = math.random(24)
if osel == 24 then if osel == 24 then
data[vi] = c_stodiam data[vi] = c_stodiam
@ -539,33 +565,27 @@ minetest.register_on_generated(function(minp, maxp, seed)
if y <= YSAND or densitybase >= trsand then if y <= YSAND or densitybase >= trsand then
data[vi] = c_sand data[vi] = c_sand
under[si] = 8 under[si] = 8
elseif n_temp < LOTET then elseif biome == 1 then -- tundra
if n_humid < MIDHUT then -- tundra data[vi] = c_permafrost
data[vi] = c_permafrost under[si] = 1
under[si] = 1 elseif biome == 2 then -- taiga
else -- taiga data[vi] = c_dirt
data[vi] = c_dirt under[si] = 2
under[si] = 2 elseif biome == 3 then -- dry grassland
end data[vi] = c_dirt
elseif n_temp > HITET then under[si] = 3
if n_humid < LOHUT then -- desert elseif biome == 4 then -- forest / grassland
data[vi] = c_desand data[vi] = c_dirt
under[si] = 5 under[si] = 4
elseif n_humid > HIHUT then -- rainforest elseif biome == 5 then -- desert
data[vi] = c_dirt data[vi] = c_desand
under[si] = 7 under[si] = 5
else -- savanna elseif biome == 6 then -- savanna
data[vi] = c_dirt data[vi] = c_dirt
under[si] = 6 under[si] = 6
end elseif biome == 7 then -- rainforest
else data[vi] = c_dirt
if n_humid < MIDHUT then -- dry grassland under[si] = 7
data[vi] = c_dirt
under[si] = 3
else -- deciduous forest / grassland
data[vi] = c_dirt
under[si] = 4
end
end end
elseif y <= YWATER and density < tstone elseif y <= YWATER and density < tstone
and nodid ~= c_stone then -- sea water and nodid ~= c_stone then -- sea water

View File

@ -7,6 +7,15 @@ minetest.register_node("riverdev:stone", {
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
minetest.register_node("riverdev:redstone", {
description = "Red Stone",
tiles = {"default_desert_stone.png"},
is_ground_content = false,
groups = {cracky=3},
drop = "default:desert_cobble",
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("riverdev:dirt", { minetest.register_node("riverdev:dirt", {
description = "Dirt", description = "Dirt",
tiles = {"default_dirt.png"}, tiles = {"default_dirt.png"},