Unlimited size. Flolands nodes. Tunnels
This commit is contained in:
parent
e832a29c00
commit
bbb5bdca1c
@ -1,4 +1,4 @@
|
|||||||
floatindev 0.2.0 by paramat
|
floatindev 0.3.0 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
|
260
init.lua
260
init.lua
@ -1,53 +1,58 @@
|
|||||||
-- floatindev 0.2.0 by paramat
|
-- floatindev 0.3.0 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
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local YMIN = 128 -- Approximate realm limits.
|
local YMIN = 1 -- Approximate realm limits.
|
||||||
local YMAX = 33000
|
local YMAX = 33000
|
||||||
local XMIN = -33000
|
local XMIN = -33000
|
||||||
local XMAX = 33000
|
local XMAX = 33000
|
||||||
local ZMIN = -33000
|
local ZMIN = -33000
|
||||||
local ZMAX = 33000
|
local ZMAX = 33000
|
||||||
|
|
||||||
local CHUINT = 2 -- Chunk interval for floatland layers
|
local CHUINT = 8 -- Chunk interval for floatland layers
|
||||||
local WAVAMP = 16 -- Structure wave amplitude
|
local WAVAMP = 48 -- Structure wave amplitude
|
||||||
local HISCAL = 24 -- Upper structure vertical scale
|
local HISCAL = 96 -- Upper structure vertical scale
|
||||||
local LOSCAL = 24 -- Lower structure vertical scale
|
local LOSCAL = 96 -- Lower structure vertical scale
|
||||||
local HIEXP = 0.5 -- Upper structure density gradient exponent
|
local HIEXP = 0.33 -- Upper structure density gradient exponent
|
||||||
local LOEXP = 0.5 -- Lower structure density gradient exponent
|
local LOEXP = 0.33 -- Lower structure density gradient exponent
|
||||||
local CLUSAV = 0 -- Large scale variation average
|
local CLUSAV = 0 -- Large scale variation average
|
||||||
local CLUSAM = 0 -- Large scale variation amplitude
|
local CLUSAM = 0 -- Large scale variation amplitude
|
||||||
local DIRTHR = 0.04 -- Dirt density threshold
|
local TSTONE = 0.1 -- Stone density threshold
|
||||||
local STOTHR = 0.08 -- Stone density threshold
|
local TTUN = 0.03 -- Tunnel width
|
||||||
local STABLE = 2 -- Minimum number of stacked stone nodes in column for dirt / sand on top
|
local TVOID = 0.6 -- Void threshold
|
||||||
|
local FLOCHA = 1 / 17 ^ 3 -- Floc chance per stone node
|
||||||
local APPCHA = 0.02 -- Appletree chance
|
|
||||||
local FLOCHA = 0.02 -- Flower chance
|
|
||||||
local GRACHA = 0.11 -- Grass chance
|
|
||||||
local ORECHA = 1 / (5 * 5 * 5)
|
|
||||||
|
|
||||||
-- 3D noise for floatlands
|
-- 3D noise for floatlands
|
||||||
|
|
||||||
local np_float = {
|
local np_float = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=256, y=256, z=256},
|
spread = {x=384, y=192, z=384},
|
||||||
seed = 277777979,
|
seed = 277777979,
|
||||||
octaves = 6,
|
octaves = 5,
|
||||||
persist = 0.6
|
persist = 0.67
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 3D noise for caves
|
-- 3D noises for tunnels
|
||||||
|
|
||||||
local np_caves = {
|
local np_weba = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=8, y=8, z=8},
|
spread = {x=128, y=128, z=128},
|
||||||
seed = -89000,
|
seed = -89000,
|
||||||
octaves = 2,
|
octaves = 3,
|
||||||
|
persist = 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
local np_webb = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1,
|
||||||
|
spread = {x=127, y=127, z=127},
|
||||||
|
seed = 85911,
|
||||||
|
octaves = 3,
|
||||||
persist = 0.5
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,26 +67,15 @@ local np_cluster = {
|
|||||||
persist = 0.5
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 2D noise for wave
|
-- 3D noise for wave
|
||||||
|
|
||||||
local np_wave = {
|
local np_wave = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x=256, y=256, z=256},
|
spread = {x=512, y=512, z=512},
|
||||||
seed = -400000000089,
|
seed = -4000000089,
|
||||||
octaves = 3,
|
octaves = 3,
|
||||||
persist = 0.5
|
persist = 0.4
|
||||||
}
|
|
||||||
|
|
||||||
-- 2D noise for biome
|
|
||||||
|
|
||||||
local np_biome = {
|
|
||||||
offset = 0,
|
|
||||||
scale = 1,
|
|
||||||
spread = {x=250, y=250, z=250},
|
|
||||||
seed = 9130,
|
|
||||||
octaves = 3,
|
|
||||||
persist = 0.5
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stuff
|
-- Stuff
|
||||||
@ -90,90 +84,29 @@ floatindev = {}
|
|||||||
|
|
||||||
-- Nodes
|
-- Nodes
|
||||||
|
|
||||||
minetest.register_node("floatindev:stone", {
|
minetest.register_node("floatindev:floatstone", {
|
||||||
description = "FLI Stone",
|
description = "Floatstone",
|
||||||
tiles = {"default_stone.png"},
|
tiles = {"floatindev_floatstone.png"},
|
||||||
is_ground_content = false, -- stops cavegen removing this node
|
is_ground_content = false, -- stops cavegen removing this node
|
||||||
groups = {cracky=3},
|
groups = {cracky=3},
|
||||||
drop = "default:cobble",
|
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("floatindev:desertstone", {
|
minetest.register_node("floatindev:floatsand", {
|
||||||
description = "FLI Desert Stone",
|
description = "Floatsand",
|
||||||
tiles = {"default_desert_stone.png"},
|
tiles = {"floatindev_floatsand.png"},
|
||||||
is_ground_content = false, -- stops cavegen removing this node
|
is_ground_content = false,
|
||||||
groups = {cracky=3},
|
groups = {crumbly=3, falling_node=1, sand=1},
|
||||||
drop = "default:desert_stone",
|
sounds = default.node_sound_sand_defaults(),
|
||||||
sounds = default.node_sound_stone_defaults(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Functions
|
minetest.register_node("floatindev:floc", {
|
||||||
|
description = "Float crystal block",
|
||||||
local function floatindev_appletree(x, y, z, area, data)
|
tiles = {"floatindev_floc.png"},
|
||||||
local c_tree = minetest.get_content_id("default:tree")
|
is_ground_content = false,
|
||||||
local c_apple = minetest.get_content_id("default:apple")
|
groups = {cracky=1},
|
||||||
local c_leaves = minetest.get_content_id("default:leaves")
|
sounds = default.node_sound_stone_defaults(),
|
||||||
for j = -2, 4 do
|
})
|
||||||
if j >= 1 then
|
|
||||||
for i = -2, 2 do
|
|
||||||
for k = -2, 2 do
|
|
||||||
local vi = area:index(x + i, y + j + 1, z + k)
|
|
||||||
if math.random(48) == 2 then
|
|
||||||
data[vi] = c_apple
|
|
||||||
elseif math.random(3) ~= 2 then
|
|
||||||
data[vi] = c_leaves
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local vi = area:index(x, y + j, z)
|
|
||||||
data[vi] = c_tree
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function floatindev_grass(data, vi)
|
|
||||||
local c_grass1 = minetest.get_content_id("default:grass_1")
|
|
||||||
local c_grass2 = minetest.get_content_id("default:grass_2")
|
|
||||||
local c_grass3 = minetest.get_content_id("default:grass_3")
|
|
||||||
local c_grass4 = minetest.get_content_id("default:grass_4")
|
|
||||||
local c_grass5 = minetest.get_content_id("default:grass_5")
|
|
||||||
local rand = math.random(5)
|
|
||||||
if rand == 1 then
|
|
||||||
data[vi] = c_grass1
|
|
||||||
elseif rand == 2 then
|
|
||||||
data[vi] = c_grass2
|
|
||||||
elseif rand == 3 then
|
|
||||||
data[vi] = c_grass3
|
|
||||||
elseif rand == 4 then
|
|
||||||
data[vi] = c_grass4
|
|
||||||
else
|
|
||||||
data[vi] = c_grass5
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function floatindev_flower(data, vi)
|
|
||||||
local c_danwhi = minetest.get_content_id("flowers:dandelion_white")
|
|
||||||
local c_danyel = minetest.get_content_id("flowers:dandelion_yellow")
|
|
||||||
local c_rose = minetest.get_content_id("flowers:rose")
|
|
||||||
local c_tulip = minetest.get_content_id("flowers:tulip")
|
|
||||||
local c_geranium = minetest.get_content_id("flowers:geranium")
|
|
||||||
local c_viola = minetest.get_content_id("flowers:viola")
|
|
||||||
local rand = math.random(6)
|
|
||||||
if rand == 1 then
|
|
||||||
data[vi] = c_danwhi
|
|
||||||
elseif rand == 2 then
|
|
||||||
data[vi] = c_rose
|
|
||||||
elseif rand == 3 then
|
|
||||||
data[vi] = c_tulip
|
|
||||||
elseif rand == 4 then
|
|
||||||
data[vi] = c_danyel
|
|
||||||
elseif rand == 5 then
|
|
||||||
data[vi] = c_geranium
|
|
||||||
else
|
|
||||||
data[vi] = c_viola
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- On generated function
|
-- On generated function
|
||||||
|
|
||||||
@ -183,10 +116,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
or minp.z < ZMIN or maxp.z > ZMAX then
|
or minp.z < ZMIN or maxp.z > ZMAX then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local chulay = math.floor((minp.y + 32) / 80) -- chunk layer number, 0 = surface chunk
|
|
||||||
if math.fmod(chulay, CHUINT) ~= 0 then -- if chulay / CHUINT has a remainder
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local t1 = os.clock()
|
local t1 = os.clock()
|
||||||
local x1 = maxp.x
|
local x1 = maxp.x
|
||||||
@ -203,109 +132,68 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_stodiam = minetest.get_content_id("default:stone_with_diamond")
|
|
||||||
local c_stomese = minetest.get_content_id("default:stone_with_mese")
|
|
||||||
local c_stogold = minetest.get_content_id("default:stone_with_gold")
|
|
||||||
local c_stocopp = minetest.get_content_id("default:stone_with_copper")
|
|
||||||
local c_stoiron = minetest.get_content_id("default:stone_with_iron")
|
|
||||||
local c_stocoal = minetest.get_content_id("default:stone_with_coal")
|
|
||||||
local c_grass = minetest.get_content_id("default:dirt_with_grass")
|
|
||||||
local c_dirt = minetest.get_content_id("default:dirt")
|
|
||||||
local c_desand = minetest.get_content_id("default:desert_sand")
|
|
||||||
|
|
||||||
local c_flistone = minetest.get_content_id("floatindev:stone")
|
local c_floatstone = minetest.get_content_id("floatindev:floatstone")
|
||||||
local c_flidestone = minetest.get_content_id("floatindev:desertstone")
|
local c_floatsand = minetest.get_content_id("floatindev:floatsand")
|
||||||
|
local c_floc = minetest.get_content_id("floatindev:floc")
|
||||||
|
|
||||||
local sidelen = x1 - x0 + 1
|
local sidelen = x1 - x0 + 1
|
||||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||||
local minposxyz = {x=x0, y=y0, z=z0}
|
local minposxyz = {x=x0, y=y0, z=z0}
|
||||||
local minposxz = {x=x0, y=z0}
|
|
||||||
|
|
||||||
local nvals_float = minetest.get_perlin_map(np_float, chulens):get3dMap_flat(minposxyz)
|
local nvals_float = minetest.get_perlin_map(np_float, chulens):get3dMap_flat(minposxyz)
|
||||||
local nvals_caves = minetest.get_perlin_map(np_caves, chulens):get3dMap_flat(minposxyz)
|
local nvals_weba = minetest.get_perlin_map(np_weba, chulens):get3dMap_flat(minposxyz)
|
||||||
|
local nvals_webb = minetest.get_perlin_map(np_webb, chulens):get3dMap_flat(minposxyz)
|
||||||
local nvals_cluster = minetest.get_perlin_map(np_cluster, chulens):get3dMap_flat(minposxyz)
|
local nvals_cluster = minetest.get_perlin_map(np_cluster, chulens):get3dMap_flat(minposxyz)
|
||||||
|
local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get3dMap_flat(minposxyz)
|
||||||
|
|
||||||
local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get2dMap_flat(minposxz)
|
local chulay = math.floor((minp.y + 32) / 80) -- chunk layer number, 0 = surface chunk
|
||||||
local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get2dMap_flat({x=x0+150, y=z0+50})
|
local tercen = (math.floor(chulay / CHUINT) * CHUINT + CHUINT / 2) * 80 - 32 -- terrain centre of this layer
|
||||||
|
|
||||||
local nixyz = 1
|
local nixyz = 1
|
||||||
local nixz = 1
|
local nixz = 1
|
||||||
local stable = {}
|
local stable = {}
|
||||||
local dirt = {}
|
|
||||||
local chumid = y0 + sidelen / 2
|
|
||||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||||
for x = x0, x1 do
|
for x = x0, x1 do
|
||||||
local si = x - x0 + 1
|
local si = x - x0 + 1
|
||||||
dirt[si] = 0
|
|
||||||
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
|
local nodename = minetest.get_node({x=x,y=y0-1,z=z}).name
|
||||||
if nodename == "air"
|
if nodename == "air"
|
||||||
or nodename == "default:water_source" then
|
or nodename == "default:water_source" then
|
||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
else -- all else including ignore in ungenerated chunks
|
else -- all else including ignore in ungenerated chunks
|
||||||
stable[si] = STABLE
|
stable[si] = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for y = y0, y1 do -- for each x row progressing upwards
|
for y = y0, y1 do -- for each x row progressing upwards
|
||||||
local vi = area:index(x0, y, z)
|
local vi = area:index(x0, y, z)
|
||||||
for x = x0, x1 do -- for each node do
|
for x = x0, x1 do -- for each node do
|
||||||
local si = x - x0 + 1
|
local si = x - x0 + 1
|
||||||
local flomid = chumid + nvals_wave[nixz] * WAVAMP
|
local flomid = tercen + nvals_wave[nixyz] * WAVAMP -- y of floatland middle
|
||||||
local grad
|
|
||||||
|
local grad -- density for node
|
||||||
if y > flomid then
|
if y > flomid then
|
||||||
grad = ((y - flomid) / HISCAL) ^ HIEXP
|
grad = ((y - flomid) / HISCAL) ^ HIEXP
|
||||||
else
|
else
|
||||||
grad = ((flomid - y) / LOSCAL) ^ LOEXP
|
grad = ((flomid - y) / LOSCAL) ^ LOEXP
|
||||||
end
|
end
|
||||||
local density = nvals_float[nixyz] - grad + CLUSAV + nvals_cluster[nixyz] * CLUSAM
|
local density = nvals_float[nixyz] - grad + CLUSAV + nvals_cluster[nixyz] * CLUSAM
|
||||||
if density > 0 and density < 0.7 then -- if floatland shell
|
|
||||||
if nvals_caves[nixyz] - density > -0.7 then -- if no cave
|
local weba = math.abs(nvals_weba[nixyz]) < TTUN -- check for tunnel
|
||||||
if y > flomid and density < STOTHR and stable[si] >= STABLE then
|
local webb = math.abs(nvals_webb[nixyz]) < TTUN
|
||||||
if nvals_biome[nixz] > 0.45 then -- fine materials
|
local notun = not (weba and webb)
|
||||||
data[vi] = c_desand
|
|
||||||
else
|
if density > 0 and density < TVOID and notun then -- if floatland shell
|
||||||
if density < DIRTHR then
|
if y > flomid and density < TSTONE and stable[si] >= 2 then
|
||||||
data[vi] = c_grass
|
data[vi] = c_floatsand -- sand
|
||||||
else
|
else
|
||||||
data[vi] = c_dirt
|
if math.random() < FLOCHA then
|
||||||
end
|
data[vi] = c_floc -- floc
|
||||||
dirt[si] = dirt[si] + 1
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if nvals_biome[nixz] > 0.45 then -- stone
|
data[vi] = c_floatstone -- stone
|
||||||
data[vi] = c_flidestone
|
|
||||||
elseif math.random() < ORECHA then
|
|
||||||
local osel = math.random(34)
|
|
||||||
if osel == 34 then
|
|
||||||
data[vi] = c_stodiam
|
|
||||||
elseif osel >= 31 then
|
|
||||||
data[vi] = c_stomese
|
|
||||||
elseif osel >= 28 then
|
|
||||||
data[vi] = c_stogold
|
|
||||||
elseif osel >= 19 then
|
|
||||||
data[vi] = c_stocopp
|
|
||||||
elseif osel >= 10 then
|
|
||||||
data[vi] = c_stoiron
|
|
||||||
else
|
|
||||||
data[vi] = c_stocoal
|
|
||||||
end
|
|
||||||
else
|
|
||||||
data[vi] = c_flistone
|
|
||||||
end
|
|
||||||
stable[si] = stable[si] + 1
|
|
||||||
end
|
end
|
||||||
else -- cave
|
stable[si] = stable[si] + 1
|
||||||
stable[si] = 0
|
|
||||||
end
|
end
|
||||||
elseif y > flomid and density < 0 and dirt[si] >= 1 then -- node above surface dirt
|
else -- air
|
||||||
if dirt[si] >= 2 and math.random() < APPCHA then
|
|
||||||
floatindev_appletree(x, y, z, area, data)
|
|
||||||
elseif math.random() < FLOCHA then
|
|
||||||
floatindev_flower(data, vi)
|
|
||||||
elseif math.random() < GRACHA then
|
|
||||||
floatindev_grass(data, vi)
|
|
||||||
end
|
|
||||||
dirt[si] = 0
|
|
||||||
else -- atmosphere
|
|
||||||
stable[si] = 0
|
stable[si] = 0
|
||||||
end
|
end
|
||||||
nixyz = nixyz + 1
|
nixyz = nixyz + 1
|
||||||
|
BIN
textures/floatindev_floatsand.png
Normal file
BIN
textures/floatindev_floatsand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 723 B |
BIN
textures/floatindev_floatstone.png
Normal file
BIN
textures/floatindev_floatstone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 541 B |
BIN
textures/floatindev_floc.png
Normal file
BIN
textures/floatindev_floc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 206 B |
Loading…
x
Reference in New Issue
Block a user