Remove generation limits, rivers/river noise, swampwater, papyrus. Noise buffer optimisation. Improve code style. Add flowers to grassland. Remove non-rotatable plantlike mod nodes, use default nodes instead. Tune parameters

master
paramat 2016-05-19 06:21:53 +01:00
parent 3af6b663b9
commit 859ca47ab4
6 changed files with 157 additions and 393 deletions

View File

@ -1,4 +1,18 @@
flexrealm 0.4.7 by paramat
For Minetest 0.4.12 and later
flexrealm 0.5.0 by paramat
For Minetest 0.4.14 and later
Depends default
Licenses: code WTFPL, textures CC BY-SA
Version changes:
Make nodes not attached to avoid falling grasses.
Fewer octaves for heat/humidity.
Remove rivers.
Noise buffer optimisation.
Improve code style.
Reduce number of upvalues.
Remove generation limits.
Add flowers to grassland.
Remove non-rotatable plantlike nodes, use defualt nodes.
Remove swampwater/papyrus.

View File

@ -1,6 +1,6 @@
function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local c_tree = minetest.get_content_id("default:tree")
local c_apple = minetest.get_content_id("flexrealm:apple")
local c_apple = minetest.get_content_id("default:apple")
local c_leaves = minetest.get_content_id("flexrealm:leaves")
if nodrot == 12 then
for i = -1, 5 do
@ -10,7 +10,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x + i + 1, y + j, z + k)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -30,7 +29,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x - i - 1, y + j, z + k)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -50,7 +48,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x + i, y + j + 1, z + k)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -70,7 +67,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x + i, y - j - 1, z + k)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -90,7 +86,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x + i, y + j, z + k + 1)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -110,7 +105,6 @@ function flexrealm_appletree(x, y, z, nodrot, area, data, p2data)
local vil = area:index(x + i, y + j, z - k - 1)
if math.random(48) == 2 then
data[vil] = c_apple
p2data[vil] = nodrot
elseif math.random(5) ~= 2 then
data[vil] = c_leaves
p2data[vil] = nodrot
@ -243,11 +237,11 @@ end
function flexrealm_grass(x, y, z, nodrot, area, data, p2data)
local c_grass1 = minetest.get_content_id("flexrealm:grass_1")
local c_grass2 = minetest.get_content_id("flexrealm:grass_2")
local c_grass3 = minetest.get_content_id("flexrealm:grass_3")
local c_grass4 = minetest.get_content_id("flexrealm:grass_4")
local c_grass5 = minetest.get_content_id("flexrealm:grass_5")
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 via
if nodrot == 12 then
via = area:index(x + 1, y, z)
@ -274,12 +268,11 @@ function flexrealm_grass(x, y, z, nodrot, area, data, p2data)
else
data[via] = c_grass5
end
p2data[via] = nodrot
end
function flexrealm_dryshrub(x, y, z, nodrot, area, data, p2data)
local c_dryshrub = minetest.get_content_id("flexrealm:dry_shrub")
local c_dryshrub = minetest.get_content_id("default:dry_shrub")
local via
if nodrot == 12 then
via = area:index(x + 1, y, z)
@ -295,12 +288,11 @@ function flexrealm_dryshrub(x, y, z, nodrot, area, data, p2data)
via = area:index(x , y , z - 1)
end
data[via] = c_dryshrub
p2data[via] = nodrot
end
function flexrealm_jungrass(x, y, z, nodrot, area, data, p2data)
local c_jungrass = minetest.get_content_id("flexrealm:junglegrass")
local c_jungrass = minetest.get_content_id("default:junglegrass")
local via
if nodrot == 12 then
via = area:index(x + 1, y, z)
@ -316,60 +308,53 @@ function flexrealm_jungrass(x, y, z, nodrot, area, data, p2data)
via = area:index(x , y , z - 1)
end
data[via] = c_jungrass
p2data[via] = nodrot
end
function flexrealm_papyrus(x, y, z, nodrot, area, data, p2data)
local c_papyrus = minetest.get_content_id("flexrealm:papyrus")
local c_papyrus = minetest.get_content_id("default:papyrus")
local ph = math.random(2, 5)
if nodrot == 12 then
for i = 1, ph do
local vip = area:index(x + i, y, z)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
elseif nodrot == 16 then
for i = 1, ph do
local vip = area:index(x - i, y, z)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
elseif nodrot == 0 then
for j = 1, ph do
local vip = area:index(x, y + j, z)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
elseif nodrot == 20 then
for j = 1, ph do
local vip = area:index(x, y - j, z)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
elseif nodrot == 4 then
for k = 1, ph do
local vip = area:index(x, y, z + k)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
elseif nodrot == 8 then
for k = 1, ph do
local vip = area:index(x, y, z - k)
data[vip] = c_papyrus
p2data[vip] = nodrot
end
end
end
function flexrealm_flower(x, y, z, nodrot, area, data, p2data)
local c_danwhi = minetest.get_content_id("flexrealm:dandelion_white")
local c_danyel = minetest.get_content_id("flexrealm:dandelion_yellow")
local c_rose = minetest.get_content_id("flexrealm:rose")
local c_tulip = minetest.get_content_id("flexrealm:tulip")
local c_geranium = minetest.get_content_id("flexrealm:geranium")
local c_viola = minetest.get_content_id("flexrealm:viola")
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 via
if nodrot == 12 then
via = area:index(x + 1, y, z)
@ -398,7 +383,6 @@ function flexrealm_flower(x, y, z, nodrot, area, data, p2data)
else
data[via] = c_viola
end
p2data[via] = nodrot
end
@ -466,4 +450,3 @@ function flexrealm_cactus(x, y, z, nodrot, area, data, p2data)
end
end
end

233
init.lua
View File

@ -1,24 +1,17 @@
-- Variables
local flat = false -- Normal flat realm
local vertical = false -- Vertical flat realm facing south
local invert = false -- Inverted flat realm
local planet = false -- Planet sphere
local dysonsphere = false -- Dyson sphere
local tube = true -- East-West tube world / O'Neill space colony
local cube = false -- Planet cube
local dysoncube = false -- Dyson cube
local limit = {
XMIN = -33000, -- Limits for all realm types
XMAX = 33000,
YMIN = -33000,
YMAX = 33000,
ZMIN = -33000,
ZMAX = 33000,
local realm = {
flat = false, -- Normal flat realm
vertical = false, -- Vertical flat realm facing south
invert = false, -- Inverted flat realm
planet = true, -- Planet sphere
dysonsphere = false, -- Dyson sphere
tube = false, -- East-West tube world / O'Neill space colony
cube = false, -- Planet cube
dysoncube = false, -- Dyson cube
}
local TERRS = 32 -- Terrain scale for all realms below
local TERRS = 64 -- Terrain scale for all realms below
-- Normal and inverted flat realms
local FLATY = 0 -- Surface y
-- Vertical flat realm facing south
@ -27,7 +20,7 @@ local VERTZ = 0 -- Surface z
local SPHEX = 0 -- Centre x
local SPHEZ = 0 -- ..z
local SPHEY = 0 -- ..y
local SPHER = 128 -- Surface radius
local SPHER = 2048 -- Surface radius
-- Tube world
local TUBEZ = 0 -- Axis z
local TUBEY = 0 -- ..y
@ -45,30 +38,26 @@ local DEPT = 2 -- Realm +-depth density threshold
local ROCK = -1 -- Rocky terrain density threshold
local CLOLOT = -0.9 -- Cloud low density threshold
local CLOHIT = -0.89 -- Cloud high density threshold
-- Noise thresholds for density field 'density'
-- Noise thresholds for density field 'density' TODO (auto?) tune these
local TSAND = -0.04 -- Sand density threshold
local TSTONE = 0.1 -- Stone density threshold at sea level
local TDIRT = 0.05 -- Dirt density threshold
local TSURF = 0.1 -- Surface density threshold for flora generation
-- Other parameters
local TFIS = 0.04 -- Fissure width noise threshold
local OCHA = 7*7*7 -- Ore 1/x chance per stone node
local TFIS = 0.01 -- Fissure width noise threshold
local OCHA = 7 * 7 * 7 -- Ore 1/x chance per stone node
local TCLOUD = 0.5 -- Cloud threshold, -2 = overcast, 2 = no cloud
local HITET = 0.4 -- High temperature noise threshold
local LOTET = -0.4 -- Low temperature noise threshold
local ICETET = -0.8 -- Icesheet / glacier temperature threshold
local HUT = 0 -- -- Humidity noise threshold
local flora = {
APPCHA = 49, -- Apple tree maximum 1/x chance per surface node
FLOCHA = 47 ^ 2, -- Flower 1/x chance per surface node
GRACHA = 9, -- Grass 1/x chance per surface node
PINCHA = 49, -- Pine tree maximum 1/x chance per surface node
JUTCHA = 16, -- Jungle tree maximum 1/x chance per surface node
JUGCHA = 16, -- Jungle tree maximum 1/x chance per surface node
PAPCHA = 3, -- Papyrus 1/x chance per surface swamp water node
CACCHA = 361, -- Cactus 1/x chance per surface node
APPCHA = 128, -- Apple tree maximum 1/x chance per surface node
FLOCHA = 64, -- Flower 1/x chance per surface node
GRACHA = 8, -- Grass 1/x chance per surface node
PINCHA = 128, -- Pine tree maximum 1/x chance per surface node
JUTCHA = 32, -- Jungle tree maximum 1/x chance per surface node
JUGCHA = 8, -- Jungle grass maximum 1/x chance per surface node
PAPCHA = 8, -- Papyrus 1/x chance per surface swamp water node
CACCHA = 256, -- Cactus 1/x chance per surface node
}
-- Noise parameters
@ -78,10 +67,10 @@ local flora = {
local np_terrain = {
offset = 0,
scale = 1,
spread = {x=48, y=48, z=48},
spread = {x = 96, y = 96, z = 96},
seed = 92,
octaves = 2,
persist = 0.63
octaves = 3,
persist = 0.6
}
-- 3D noise for smooth terrain
@ -89,9 +78,9 @@ local np_terrain = {
local np_smooth = {
offset = 0,
scale = 1,
spread = {x=78, y=78, z=78},
spread = {x = 192, y = 192, z = 192},
seed = 800911,
octaves = 1,
octaves = 3,
persist = 0.4
}
@ -100,31 +89,20 @@ local np_smooth = {
local np_terblen = {
offset = 0,
scale = 1,
spread = {x=64, y=64, z=64},
spread = {x = 192, y = 192, z = 192},
seed = -440002,
octaves = 3,
octaves = 1,
persist = 0.4
}
-- 3D noise for rivers
local np_river = {
offset = 0,
scale = 1,
spread = {x=384, y=384, z=384},
seed = 14440002,
octaves = 4,
persist = 0.5
}
-- 3D noise for temperature
local np_temp = {
offset = 0,
scale = 1,
spread = {x=48, y=48, z=48},
spread = {x = 384, y = 384, z = 384},
seed = 9130,
octaves = 3,
octaves = 2,
persist = 0.4
}
@ -133,9 +111,9 @@ local np_temp = {
local np_humid = {
offset = 0,
scale = 1,
spread = {x=48, y=48, z=48},
spread = {x = 384, y = 384, z = 384},
seed = -55500,
octaves = 3,
octaves = 2,
persist = 0.4
}
@ -144,9 +122,9 @@ local np_humid = {
local np_fissure = {
offset = 0,
scale = 1,
spread = {x=48, y=48, z=48},
spread = {x = 192, y = 192, z = 192},
seed = 108881,
octaves = 2,
octaves = 3,
persist = 0.5
}
@ -155,41 +133,45 @@ local np_fissure = {
local np_cloud = {
offset = 0,
scale = 1,
spread = {x=104, y=104, z=104},
spread = {x = 96, y = 96, z = 96},
seed = 2113,
octaves = 4,
octaves = 3,
persist = 0.7
}
-- Stuff
-- Do files
dofile(minetest.get_modpath("flexrealm").."/nodes.lua")
dofile(minetest.get_modpath("flexrealm").."/functions.lua")
dofile(minetest.get_modpath("flexrealm") .. "/nodes.lua")
dofile(minetest.get_modpath("flexrealm") .. "/functions.lua")
minetest.register_on_mapgen_init(function(mgparams)
minetest.set_mapgen_params({mgname="singlenode", flags="nolight", water_level=-31000})
end)
-- Mapgen parameters
minetest.set_mapgen_params({mgname = "singlenode",
flags = "nolight", water_level = -31000})
-- Initialize noise objects to nil
local nobj_terrain = nil
local nobj_smooth = nil
local nobj_terblen = nil
local nobj_river = nil
local nobj_fissure = nil
local nobj_temp = nil
local nobj_humid = nil
local nobj_cloud = nil
-- Localise noise buffers
local nbuf_terrain
local nbuf_smooth
local nbuf_terblen
local nbuf_fissure
local nbuf_temp
local nbuf_humid
local nbuf_cloud
-- On generated function
minetest.register_on_generated(function(minp, maxp, seed)
if minp.x < limit.XMIN or maxp.x > limit.XMAX
or minp.y < limit.YMIN or maxp.y > limit.YMAX
or minp.z < limit.ZMIN or maxp.z > limit.ZMAX then
return
end
local t0 = os.clock()
local x0 = minp.x
local y0 = minp.y
@ -218,36 +200,33 @@ minetest.register_on_generated(function(minp, maxp, seed)
local c_flrcloud = minetest.get_content_id("flexrealm:cloud")
local c_flrperfrost = minetest.get_content_id("flexrealm:perfrost")
local c_flrwatzero = minetest.get_content_id("flexrealm:watzero")
local c_flrswatzero = minetest.get_content_id("flexrealm:swatzero")
local c_flrlavazero = minetest.get_content_id("flexrealm:lavazero")
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
local data = vm:get_data()
local p2data = vm:get_param2_data()
local sidelen = x1 - x0 + 1
local facearea = sidelen ^ 2
local chulens = {x=sidelen, y=sidelen, z=sidelen}
local minpos = {x=x0, y=y0, z=z0}
local chulens = {x = sidelen, y = sidelen, z = sidelen}
local minpos = {x = x0, y = y0, z = z0}
nobj_terrain = nobj_terrain or minetest.get_perlin_map(np_terrain, chulens)
nobj_smooth = nobj_smooth or minetest.get_perlin_map(np_smooth, chulens)
nobj_terblen = nobj_terblen or minetest.get_perlin_map(np_terblen, chulens)
nobj_river = nobj_river or minetest.get_perlin_map(np_river, chulens)
nobj_fissure = nobj_fissure or minetest.get_perlin_map(np_fissure, chulens)
nobj_temp = nobj_temp or minetest.get_perlin_map(np_temp, chulens)
nobj_humid = nobj_humid or minetest.get_perlin_map(np_humid, chulens)
nobj_cloud = nobj_cloud or minetest.get_perlin_map(np_cloud, chulens)
local nvals_terrain = nobj_terrain:get3dMap_flat(minpos)
local nvals_smooth = nobj_smooth:get3dMap_flat(minpos)
local nvals_terblen = nobj_terblen:get3dMap_flat(minpos)
local nvals_river = nobj_river:get3dMap_flat(minpos)
local nvals_fissure = nobj_fissure:get3dMap_flat(minpos)
local nvals_temp = nobj_temp:get3dMap_flat(minpos)
local nvals_humid = nobj_humid:get3dMap_flat(minpos)
local nvals_cloud = nobj_cloud:get3dMap_flat(minpos)
local nvals_terrain = nobj_terrain:get3dMap_flat(minpos, nbuf_terrain)
local nvals_smooth = nobj_smooth:get3dMap_flat(minpos, nbuf_smooth)
local nvals_terblen = nobj_terblen:get3dMap_flat(minpos, nbuf_terblen)
local nvals_fissure = nobj_fissure:get3dMap_flat(minpos, nbuf_fissure)
local nvals_temp = nobj_temp:get3dMap_flat(minpos, nbuf_temp)
local nvals_humid = nobj_humid:get3dMap_flat(minpos, nbuf_humid)
local nvals_cloud = nobj_cloud:get3dMap_flat(minpos, nbuf_cloud)
local ni = 1
for z = z0, z1 do
@ -261,33 +240,34 @@ minetest.register_on_generated(function(minp, maxp, seed)
local terno = nvals_terrain[ni] * (1 - terblen) + nvals_smooth[ni] * terblen
-- noise gradient
local grad, sphexr, spheyr, sphezr, tubeyr, tubezr, cubexr, cubeyr, cubezr
if flat then
if realm.flat then
grad = (FLATY - y) / TERRS
elseif vertical then
elseif realm.vertical then
grad = (z - VERTZ) / TERRS
elseif invert then
elseif realm.invert then
grad = (y - FLATY) / TERRS
elseif planet or dysonsphere then
elseif realm.planet or realm.dysonsphere then
sphexr = x - SPHEX
spheyr = y - SPHEY
sphezr = z - SPHEZ
local nodrad = math.sqrt(sphexr ^ 2 + spheyr ^ 2 + sphezr ^ 2)
if dysonsphere then
if realm.dysonsphere then
grad = (nodrad - SPHER) / TERRS
else
grad = (SPHER - nodrad) / TERRS
end
elseif tube then
elseif realm.tube then
tubeyr = y - TUBEY
tubezr = z - TUBEZ
local nodrad = math.sqrt(tubeyr ^ 2 + tubezr ^ 2)
grad = (nodrad - TUBER) / TERRS
elseif cube or dysoncube then
elseif realm.cube or realm.dysoncube then
cubexr = x - CUBEX
cubeyr = y - CUBEY
cubezr = z - CUBEZ
local noddis = math.max(math.abs(cubexr), math.abs(cubeyr), math.abs(cubezr))
if dysoncube then
local noddis = math.max(math.abs(cubexr),
math.abs(cubeyr), math.abs(cubezr))
if realm.dysoncube then
grad = (noddis - CUBER) / TERRS
else
grad = (CUBER - noddis) / TERRS
@ -295,7 +275,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
-- density field
local density
if tube then
if realm.tube then
if math.abs(x) > TUBEX then -- endcaps
local wall = ((math.abs(x) - TUBEX) / TUBED) ^ 2 * TUBER / TERRS
density = terno + grad + wall
@ -319,19 +299,19 @@ minetest.register_on_generated(function(minp, maxp, seed)
local n_humid = nvals_humid[ni]
local humid = n_humid + grad
if density > 0 or grad > 0 then -- if terrain or water calculate biome
if temp > HITET then
if humid > HUT then
if temp > 0.3 then
if humid > 0.0 then
rainforest = true
else
desert = true
end
elseif temp < LOTET then
if humid < HUT then
elseif temp < -0.3 then
if humid < 0.0 then
tundra = true
else
taiga = true
end
elseif humid > HUT then
elseif humid > 0.0 then
forest = true
else
grassland = true
@ -350,13 +330,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- nodrot 0 = y+, 12 = x+, 16 = x-, 4 = z+, 8 = z-, 20 = y-
local nodrot = 0
if surf then
if flat then
if realm.flat then
nodrot = 0
elseif vertical then
elseif realm.vertical then
nodrot = 8
elseif invert then
elseif realm.invert then
nodrot = 20
elseif planet then
elseif realm.planet then
if spheyr > math.abs(sphexr)
and spheyr > math.abs(sphezr) then
nodrot = 0
@ -376,7 +356,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
and sphezr < -math.abs(spheyr) then
nodrot = 8
end
elseif dysonsphere then
elseif realm.dysonsphere then
if spheyr > math.abs(sphexr)
and spheyr > math.abs(sphezr) then
nodrot = 20
@ -396,7 +376,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
and sphezr < -math.abs(spheyr) then
nodrot = 4
end
elseif tube then
elseif realm.tube then
if tubeyr > math.abs(tubezr) then
nodrot = 20
elseif tubeyr < -math.abs(tubezr) then
@ -406,7 +386,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
elseif tubezr < -math.abs(tubeyr) then
nodrot = 4
end
elseif cube then
elseif realm.cube then
if cubeyr > math.abs(cubexr)
and cubeyr > math.abs(cubezr) then
nodrot = 0
@ -426,7 +406,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
and cubezr < -math.abs(cubeyr) then
nodrot = 8
end
elseif dysoncube then
elseif realm.dysoncube then
if cubeyr > math.abs(cubexr)
and cubeyr > math.abs(cubezr) then
nodrot = 20
@ -449,23 +429,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
-- mapgen
local n_riverabs = math.abs(nvals_river[ni]) -- river water / glacier
if n_riverabs <= 0.03 * (1 - (density / 0.25) ^ 2) * altprop
and grad <= 0.12 and (density > 0 or grad > 0) then
if grad > 0.1 and density > 0 then
data[vi] = c_flrsand
elseif density >= 0.1 or grad > 0 then
if temp < ICETET then
data[vi] = c_ice
else
data[vi] = c_flrwatzero
end
end
elseif n_riverabs > 0.03 * (1 - (density / 0.25) ^ 2) * altprop -- river sand
and n_riverabs <= 0.04 * (1 - (density / 0.3) ^ 2) * altprop
and grad < 0.12 and density >= 0.1 then
data[vi] = c_flrsand
elseif (density >= tstone and grad <= DEPT and nofis) then -- stone
if (density >= tstone and grad <= DEPT and nofis) then -- stone
if (density >= 0.5 and density <= 0.55)
or (density >= 0.3 and density <= 0.4)
or (density >= 0.2 and density <= 0.25) then
@ -524,6 +488,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
data[vi] = c_flrgrass
if surf and math.random(flora.GRACHA) == 2 then
flexrealm_grass(x, y, z, nodrot, area, data, p2data)
elseif surf and math.random(flora.FLOCHA) == 2 then
flexrealm_flower(x, y, z, nodrot, area, data, p2data)
end
elseif rainforest then
data[vi] = c_flrgrass
@ -541,21 +507,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
end
elseif temp < ICETET and grad > 0 and grad <= 0.05 and density <= 0 then -- sea ice
elseif temp < -0.6 and grad > 0 and grad <= 0.05 and density <= 0 then -- sea ice
if nodid == c_air then
data[vi] = c_ice
end
elseif grad > 0 and density <= 0 then -- sea water / swamp water
elseif grad > 0 and density <= 0 then -- sea water
if nodid == c_air then
if n_terblen > 0.2 and density > -0.01 + (math.random() - 0.5) * 0.005
and grad < 0.02 and (desert or rainforest) then
data[vi] = c_flrswatzero
if math.random(flora.PAPCHA) == 2 then -- papyrus
flexrealm_papyrus(x, y, z, nodrot, area, data, p2data)
end
else
data[vi] = c_flrwatzero
end
data[vi] = c_flrwatzero
end
elseif grad >= CLOLOT and grad <= CLOHIT then -- clouds
local xrq = 16 * math.floor((x - x0) / 16)
@ -580,6 +538,5 @@ minetest.register_on_generated(function(minp, maxp, seed)
vm:update_liquids()
local chugent = math.ceil((os.clock() - t0) * 1000)
print ("[flexrealm] "..chugent.." ms minp ("..x0.." "..y0.." "..z0..")")
print ("[flexrealm] " .. chugent)
end)

252
nodes.lua
View File

@ -1,37 +1,37 @@
minetest.register_node("flexrealm:dirt", {
description = "Flexrealm Dirt",
tiles = {"default_dirt.png"},
groups = {crumbly=3,soil=1},
groups = {crumbly = 3, soil = 1},
sounds = default.node_sound_dirt_defaults(),
})
minetest.register_node("flexrealm:grass", {
description = "Flexrealm Grass",
tiles = {"default_grass.png"},
groups = {crumbly=3,soil=1},
groups = {crumbly = 3, soil = 1},
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
footstep = {name = "default_grass_footstep", gain = 0.4},
}),
})
minetest.register_node("flexrealm:sand", {
description = "Flexrealm Sand",
tiles = {"default_sand.png"},
groups = {crumbly=3, sand=1},
groups = {crumbly = 3, sand = 1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node("flexrealm:desand", {
description = "Flexrealm Desert Sand",
tiles = {"default_desert_sand.png"},
groups = {crumbly=3, sand=1},
groups = {crumbly = 3, sand = 1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node("flexrealm:stone", {
description = "Flexrealm Stone",
tiles = {"default_stone.png"},
groups = {cracky=3, stone=1},
groups = {cracky = 3, stone = 1},
drop = "default:cobble",
sounds = default.node_sound_stone_defaults(),
})
@ -39,7 +39,7 @@ minetest.register_node("flexrealm:stone", {
minetest.register_node("flexrealm:destone", {
description = "Flexrealm Desert Stone",
tiles = {"default_desert_stone.png"},
groups = {cracky=3, stone=1},
groups = {cracky = 3, stone = 1},
drop = "default:desert_stone",
sounds = default.node_sound_stone_defaults(),
})
@ -47,7 +47,7 @@ minetest.register_node("flexrealm:destone", {
minetest.register_node("flexrealm:perfrost", {
description = "Flexrealm Permafrost",
tiles = {"flexrealm_perfrost.png"},
groups = {crumbly=1},
groups = {crumbly = 1},
drop = "default:dirt",
sounds = default.node_sound_dirt_defaults(),
})
@ -62,12 +62,10 @@ minetest.register_node("flexrealm:cloud", {
pointable = false,
diggable = false,
buildable_to = true,
post_effect_color = {a=23, r=241, g=248, b=255},
groups = {not_in_creative_inventory=1},
post_effect_color = {a = 23, r = 241, g = 248, b = 255},
groups = {not_in_creative_inventory = 1},
})
-- Rotated nodes
minetest.register_node("flexrealm:leaves", {
description = "Flexrealm Leaves",
drawtype = "allfaces_optional",
@ -76,22 +74,7 @@ minetest.register_node("flexrealm:leaves", {
tiles = {"default_leaves.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3, flammable=2, leaves=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:apple", {
description = "Flexrealm Apple",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_apple.png"},
inventory_image = "default_apple.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3,flammable=2},
drop = "default:apple",
groups = {snappy = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
})
@ -103,7 +86,7 @@ minetest.register_node("flexrealm:jungleleaves", {
tiles = {"default_jungleleaves.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3, flammable=2, leaves=1},
groups = {snappy = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
})
@ -115,7 +98,7 @@ minetest.register_node("flexrealm:pine_needles",{
waving = 1,
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3, flammable=2, leaves=1},
groups = {snappy = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
})
@ -123,165 +106,12 @@ minetest.register_node("flexrealm:cactus", {
description = "Flexrealm Cactus",
tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=3,flammable=2},
groups = {snappy = 1, choppy = 3, flammable = 2},
drop = "default:cactus",
sounds = default.node_sound_wood_defaults(),
on_place = minetest.rotate_node
})
minetest.register_node("flexrealm:papyrus", {
description = "Flexrealm Papyrus",
drawtype = "plantlike",
tiles = {"default_papyrus.png"},
inventory_image = "default_papyrus.png",
wield_image = "default_papyrus.png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
groups = {snappy=3,flammable=2},
drop = "default:papyrus",
sounds = default.node_sound_leaves_defaults(),
})
for i=1,5 do
minetest.register_node("flexrealm:grass_"..i, {
description = "Flexrealm Grass",
drawtype = "plantlike",
waving = 1,
tiles = {"default_grass_"..i..".png"},
inventory_image = "default_grass_"..i..".png",
wield_image = "default_grass_"..i..".png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
sounds = default.node_sound_leaves_defaults(),
})
end
minetest.register_node("flexrealm:dry_shrub", {
description = "Flexrealm Dry Shrub",
drawtype = "plantlike",
waving = 1,
visual_scale = 1.0,
tiles = {"default_dry_shrub.png"},
inventory_image = "default_dry_shrub.png",
wield_image = "default_dry_shrub.png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=3,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:junglegrass", {
description = "Flexrealm Jungle Grass",
drawtype = "plantlike",
waving = 1,
visual_scale = 1.3,
tiles = {"default_junglegrass.png"},
inventory_image = "default_junglegrass.png",
wield_image = "default_junglegrass.png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:rose", {
description = "Flexrealm Rose",
drawtype = "plantlike",
tiles = { "flowers_rose.png" },
inventory_image = "flowers_rose.png",
wield_image = "flowers_rose.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:tulip", {
description = "Flexrealm Tulip",
drawtype = "plantlike",
tiles = { "flowers_tulip.png" },
inventory_image = "flowers_tulip.png",
wield_image = "flowers_tulip.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:dandelion_yellow", {
description = "Flexrealm Yellow Dandelion",
drawtype = "plantlike",
tiles = { "flowers_dandelion_yellow.png" },
inventory_image = "flowers_dandelion_yellow.png",
wield_image = "flowers_dandelion_yellow.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:geranium", {
description = "Flexrealm Blue Geranium",
drawtype = "plantlike",
tiles = { "flowers_geranium.png" },
inventory_image = "flowers_geranium.png",
wield_image = "flowers_geranium.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:viola", {
description = "Flexrealm Viola",
drawtype = "plantlike",
tiles = { "flowers_viola.png" },
inventory_image = "flowers_viola.png",
wield_image = "flowers_viola.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("flexrealm:dandelion_white", {
description = "Flexrealm White Dandelion",
drawtype = "plantlike",
tiles = { "flowers_dandelion_white.png" },
inventory_image = "flowers_dandelion_white.png",
wield_image = "flowers_dandelion_white.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1},
sounds = default.node_sound_leaves_defaults(),
})
-- Zero range liquids
minetest.register_node("flexrealm:watzero", {
@ -290,12 +120,12 @@ minetest.register_node("flexrealm:watzero", {
drawtype = "liquid",
tiles = {
{
name="default_water_source_animated.png",
animation={
type="vertical_frames",
aspect_w=16,
aspect_h=16,
length=2.0,
name = "default_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
@ -313,27 +143,8 @@ minetest.register_node("flexrealm:watzero", {
liquid_viscosity = WATER_VISC,
liquid_renewable = false,
liquid_range = 0,
post_effect_color = {a=64, r=100, g=100, b=200},
groups = {water=3, liquid=3, puts_out_fire=1},
})
minetest.register_node("flexrealm:swatzero", {
description = "Flexrealm Swamp Water Source",
inventory_image = minetest.inventorycube("flexrealm_swatzero.png"),
tiles = {"flexrealm_swatzero.png"},
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
liquidtype = "source",
liquid_alternative_flowing = "flexrealm:swatzero",
liquid_alternative_source = "flexrealm:swatzero",
liquid_viscosity = 2,
liquid_renewable = false,
liquid_range = 0,
post_effect_color = {a=128, r=31, g=56, b=8},
groups = {water=3, liquid=3, puts_out_fire=1},
post_effect_color = {a = 64, r = 100, g = 100, b = 200},
groups = {water = 3, liquid = 3, puts_out_fire = 1},
})
minetest.register_node("flexrealm:lavazero", {
@ -342,12 +153,12 @@ minetest.register_node("flexrealm:lavazero", {
drawtype = "liquid",
tiles = {
{
name="default_lava_source_animated.png",
animation={
type="vertical_frames",
aspect_w=16,
aspect_h=16,
length=3.0,
name = "default_lava_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
},
@ -365,8 +176,7 @@ minetest.register_node("flexrealm:lavazero", {
liquid_viscosity = LAVA_VISC,
liquid_renewable = false,
liquid_range = 0,
damage_per_second = 4*2,
post_effect_color = {a=192, r=255, g=64, b=0},
groups = {lava=3, liquid=2, hot=3, igniter=1},
damage_per_second = 8,
post_effect_color = {a = 192, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, hot = 3, igniter = 1},
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B