@@ -318,7 +318,7 @@ interop.split_nodename = function(nodeName)
318
318
result_nodename = nodeName :sub (pos + 1 )
319
319
end
320
320
return result_modname , result_nodename
321
- end ;
321
+ end
322
322
323
323
-- returns a unique id for the biome, normally this is numeric but with mapgen v6 it can be a string name.
324
324
interop .get_biome_key = function (pos )
381
381
Portals
382
382
==============================]] --
383
383
384
- local addDetail_ancientPortal = nil ;
384
+ local addDetail_ancientPortal = nil
385
385
386
386
if ENABLE_PORTALS and minetest .get_modpath (" nether" ) ~= nil and minetest .global_exists (" nether" ) and nether .register_portal ~= nil then
387
387
-- The Portals API is available
@@ -398,7 +398,7 @@ if ENABLE_PORTALS and minetest.get_modpath("nether") ~= nil and minetest.global_
398
398
local coreList = cloudlands .get_island_details (
399
399
{x = island_info .x - searchRadius , z = island_info .z - searchRadius },
400
400
{x = island_info .x + searchRadius , z = island_info .z + searchRadius }
401
- );
401
+ )
402
402
403
403
-- Deterministically sample the island for a low location that isn't water.
404
404
-- Seed the prng so this function always returns the same coords for the island
@@ -486,7 +486,7 @@ if ENABLE_PORTALS and minetest.get_modpath("nether") ~= nil and minetest.global_
486
486
clust_num_ores = 6 ,
487
487
clust_size = 3 ,
488
488
y_max = nether .DEPTH_CEILING or nether .DEPTH ,
489
- y_min = nether .DEPTH_FLOOR or - 32000 ,
489
+ y_min = nether .DEPTH_FLOOR or - 32000 ,
490
490
})
491
491
492
492
local _ = {name = " air" , prob = 0 }
@@ -499,10 +499,10 @@ if ENABLE_PORTALS and minetest.get_modpath("nether") ~= nil and minetest.global_
499
499
deco_type = " schematic" ,
500
500
place_on = " nether:rack" ,
501
501
sidelen = 80 ,
502
- fill_ratio = 0.0002 ,
502
+ fill_ratio = 0.00018 ,
503
503
biomes = {" nether_caverns" },
504
504
y_max = nether .DEPTH_CEILING or nether .DEPTH ,
505
- y_min = nether .DEPTH_FLOOR or - 32000 ,
505
+ y_min = nether .DEPTH_FLOOR or - 32000 ,
506
506
schematic = {
507
507
size = {x = 4 , y = 4 , z = 1 },
508
508
data = {
@@ -587,8 +587,10 @@ if ENABLE_PORTALS and minetest.get_modpath("nether") ~= nil and minetest.global_
587
587
-- return true if pos is in the cloudlands
588
588
-- I'm doing this based off height for speed, so it sometimes gets it wrong when the
589
589
-- Hallelujah mountains start reaching the ground.
590
+ if noise_heightMap == nil then cloudlands .init () end
590
591
local largestCoreType = cloudlands .coreTypes [1 ] -- the first island type is the biggest/thickest
591
592
local island_bottom = ALTITUDE - (largestCoreType .depthMax * 0.66 ) + round (noise_heightMap :get2d ({x = pos .x , y = pos .z }))
593
+
592
594
return pos .y > math_max (40 , island_bottom )
593
595
end ,
594
596
@@ -669,7 +671,7 @@ if ENABLE_PORTALS and minetest.get_modpath("nether") ~= nil and minetest.global_
669
671
670
672
minetest .add_particlespawner (particleSpawnerDef )
671
673
672
- velocity = vector .multiply (velocity , - 1 );
674
+ velocity = vector .multiply (velocity , - 1 )
673
675
particleSpawnerDef .minvel , particleSpawnerDef .maxvel = velocity , velocity
674
676
minetest .add_particlespawner (particleSpawnerDef )
675
677
end
@@ -1145,7 +1147,7 @@ if not minetest.global_exists("SkyTrees") then -- If SkyTrees added into other m
1145
1147
1146
1148
-- returns a new position vector, rotated around (0, 0) to match the schematic rotation (provided the schematic_size is correct!)
1147
1149
local function rotatePositon (position , schematic_size , rotation )
1148
- local result = vector .new (position );
1150
+ local result = vector .new (position )
1149
1151
if rotation == 90 then
1150
1152
result .x = position .z
1151
1153
result .z = schematic_size .x - position .x - 1
@@ -1159,7 +1161,7 @@ if not minetest.global_exists("SkyTrees") then -- If SkyTrees added into other m
1159
1161
return result
1160
1162
end
1161
1163
1162
- local rotatedCenter = rotatePositon (schematicInfo .center , schematicInfo .size , rotation );
1164
+ local rotatedCenter = rotatePositon (schematicInfo .center , schematicInfo .size , rotation )
1163
1165
local treePos = vector .subtract (position , rotatedCenter )
1164
1166
1165
1167
if themeName == nil then themeName = SkyTrees .selectTheme (position , schematicInfo ) end
@@ -1211,7 +1213,7 @@ if not minetest.global_exists("SkyTrees") then -- If SkyTrees added into other m
1211
1213
plan_obj :read_from_schem_file (filename , replacements )
1212
1214
plan_obj .data .ground_y = - 1 -- prevent read_from_schem_file() from automatically adjusting the height when it encounters dirt in the schematic (SkyTrees sometimes have dirt up in their nooks)
1213
1215
plan_obj .data .facedir = round (rotation / 90 )
1214
- rotatedCenter = plan_obj :get_world_pos (vector .add (vector .multiply (schematicInfo .center , - 1 ), - 1 ), position ); -- this function performs the rotation I require, even if it's named/intended for something else.
1216
+ rotatedCenter = plan_obj :get_world_pos (vector .add (vector .multiply (schematicInfo .center , - 1 ), - 1 ), position ) -- this function performs the rotation I require, even if it's named/intended for something else.
1215
1217
plan_obj .data .anchor_pos = rotatedCenter
1216
1218
1217
1219
if DEBUG_SKYTREES then minetest .log (" info" , " building tree at " .. dump (position ) .. " rotated to " .. dump (treePos ) .. " rotatedCenter " .. dump (rotatedCenter ) .. " , " .. schematicInfo .filename ) end
@@ -1253,7 +1255,7 @@ if not minetest.global_exists("SkyTrees") then -- If SkyTrees added into other m
1253
1255
1254
1256
end
1255
1257
1256
- SkyTrees .init ();
1258
+ SkyTrees .init ()
1257
1259
1258
1260
1259
1261
--[[ ==============================
@@ -1280,7 +1282,7 @@ local function init_mapgen()
1280
1282
biomes [" Taiga" ] = {node_top = " mapgen_dirt_with_snow" , node_filler = " mapgen_dirt" , node_stone = " mapgen_stone" }
1281
1283
else
1282
1284
for k ,v in pairs (minetest .registered_biomes ) do
1283
- biomes [minetest .get_biome_id (k )] = v ;
1285
+ biomes [minetest .get_biome_id (k )] = v
1284
1286
end
1285
1287
end
1286
1288
if DEBUG then minetest .log (" info" , " registered biomes: " .. dump (biomes )) end
@@ -1328,7 +1330,7 @@ local function addCores(coreList, coreType, x1, z1, x2, z2)
1328
1330
1329
1331
-- this function is used by the API functions, so may be invoked without our on_generated
1330
1332
-- being called
1331
- cloudlands .init ();
1333
+ cloudlands .init ()
1332
1334
1333
1335
for z = math_floor (z1 / coreType .territorySize ), math_floor (z2 / coreType .territorySize ) do
1334
1336
for x = math_floor (x1 / coreType .territorySize ), math_floor (x2 / coreType .territorySize ) do
@@ -1401,12 +1403,12 @@ local function addCores(coreList, coreType, x1, z1, x2, z2)
1401
1403
break
1402
1404
end
1403
1405
end
1404
- end ;
1406
+ end
1405
1407
end
1406
1408
1407
1409
if spaceConditionMet then
1408
1410
-- all conditions met, we've located a new island core
1409
- -- minetest.log("Adding core "..x..","..y..","..z..","..radius);
1411
+ -- minetest.log("Adding core "..x..","..y..","..z..","..radius)
1410
1412
local y = round (noise_heightMap :get2d ({x = coreX , y = coreZ }))
1411
1413
local newCore = {
1412
1414
x = coreX ,
@@ -1493,7 +1495,7 @@ cloudlands.get_island_details = function(minp, maxp)
1493
1495
-- settings from rearranging islands.
1494
1496
if region_restrictions then removeUnwantedIslands (result ) end
1495
1497
1496
- return result ;
1498
+ return result
1497
1499
end
1498
1500
1499
1501
@@ -1527,7 +1529,7 @@ cloudlands.find_nearest_island = function(x, z, search_radius)
1527
1529
if result == nil or core .distance < result .distance then result = core end
1528
1530
end
1529
1531
1530
- return result ;
1532
+ return result
1531
1533
end
1532
1534
1533
1535
@@ -1536,7 +1538,7 @@ end
1536
1538
-- having to recalculate it during each call to get_height_at().
1537
1539
cloudlands .get_height_at = function (x , z , coreList )
1538
1540
1539
- local result , isWater = nil , false ;
1541
+ local result , isWater = nil , false
1540
1542
1541
1543
if coreList == nil then
1542
1544
local pos = {x = x , z = z }
@@ -1927,7 +1929,7 @@ local function addDetail_skyTree(decoration_list, core, minp, maxp)
1927
1929
end
1928
1930
end
1929
1931
1930
- local maxOffsetFromCenter = core .radius - (tree .requiredIslandRadius - 4 ); -- 4 is an arbitrary number, to allow trees to get closer to the edge
1932
+ local maxOffsetFromCenter = core .radius - (tree .requiredIslandRadius - 4 ) -- 4 is an arbitrary number, to allow trees to get closer to the edge
1931
1933
1932
1934
-- Use a known PRNG implementation
1933
1935
local prng = PcgRandom (
@@ -1973,7 +1975,7 @@ local function addDetail_skyTree(decoration_list, core, minp, maxp)
1973
1975
if DEBUG_SKYTREES then minetest .log (" info" , " core x: " .. coreX .. " y: " .. coreZ .. " treePos: " .. treePos .x .. " , y: " .. treePos .y ) end
1974
1976
1975
1977
SkyTrees .placeTree (treePos , treeAngle , tree , nil , core .biome .node_top )
1976
- return true ;
1978
+ return true
1977
1979
end
1978
1980
1979
1981
@@ -2676,7 +2678,7 @@ local function renderCores(cores, minp, maxp, blockseed)
2676
2678
if DEBUG_GEOMETRIC then surfaceNoise = SURFACEMAP_OFFSET end
2677
2679
local surface = round (surfaceNoise * 3 * (core .thickness + 1 ) * horz_easing ) -- if you change this formular then update maxSufaceRise in on_generated()
2678
2680
local coreBottom = math_floor (coreTop - (core .thickness + core .depth ))
2679
- local noisyDepthOfFiller = depth_filler ;
2681
+ local noisyDepthOfFiller = depth_filler
2680
2682
if noisyDepthOfFiller >= 3 then noisyDepthOfFiller = noisyDepthOfFiller + math_floor (randomNumbers [(x + z ) % 256 ] * 3 ) - 1 end
2681
2683
2682
2684
local yBottom = math_max (minp .y , coreBottom - 4 ) -- the -4 is for rare instances when density noise pushes the bottom of the island deeper
@@ -2713,7 +2715,7 @@ local function renderCores(cores, minp, maxp, blockseed)
2713
2715
-- ensure nodeId_top blocks also cover the rounded sides of islands (which may be lower
2714
2716
-- than the flat top), then dust the top surface.
2715
2717
if topBlockIndex >= 0 then
2716
- voxelsWereManipulated = true ;
2718
+ voxelsWereManipulated = true
2717
2719
2718
2720
-- we either have the highest block, or overdrawTop - but we don't want to set overdrawTop nodes to nodeId_top
2719
2721
-- (we will err on the side of caution when we can't distinguish the top of a island's side from overdrawTop)
@@ -2775,10 +2777,10 @@ local function renderCores(cores, minp, maxp, blockseed)
2775
2777
else
2776
2778
data [vi ] = nodeId_filler
2777
2779
end
2778
- end ;
2780
+ end
2779
2781
end
2780
2782
end
2781
- end ;
2783
+ end
2782
2784
2783
2785
end
2784
2786
end
@@ -2897,6 +2899,10 @@ cloudlands.init = function()
2897
2899
init_mapgen ()
2898
2900
init_secrets ()
2899
2901
end
2902
+ if noise_eddyField == nil then
2903
+ -- See comment in init_mapgen() about when this can be called
2904
+ minetest .log (" warning" , " cloudlands.init() unable to init - was probably invoked before the the environment was created" )
2905
+ end
2900
2906
end
2901
2907
2902
2908
local function on_generated (minp , maxp , blockseed )
@@ -2916,13 +2922,12 @@ local function on_generated(minp, maxp, blockseed)
2916
2922
return
2917
2923
end
2918
2924
2919
- cloudlands .init ();
2920
2925
local cores = cloudlands .get_island_details (minp , maxp )
2921
2926
2922
2927
if DEBUG then
2923
2928
minetest .log (" info" , " Cores for on_generated(): " .. # cores )
2924
2929
for _ ,core in pairs (cores ) do
2925
- minetest .log (" core (" .. core .x .. " ," .. core .y .. " ," .. core .z .. " ) r" .. core .radius );
2930
+ minetest .log (" core (" .. core .x .. " ," .. core .y .. " ," .. core .z .. " ) r" .. core .radius )
2926
2931
end
2927
2932
end
2928
2933
@@ -2951,4 +2956,4 @@ minetest.register_on_mapgen_init(
2951
2956
worldSeed = mgparams .seed
2952
2957
-- if DEBUG then minetest.set_mapgen_params({mgname = "singlenode"--[[, flags = "nolight"]]}) end
2953
2958
end
2954
- )
2959
+ )
0 commit comments