diff --git a/README.md b/README.md index 22d000f..1e54f19 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,16 @@ No new features are developed yet! Any new contribution please mantains most bac * tnt * mobs -#### conflicts +#### configurations -This mod adds a dimension in the depths of the map, the [Morlendor](#mordenlor), **configurable**, -layer and in future autodetect the `nether` and `caverealms` layers to avoid conflicts. +This mod adds a dimension in the depths of the map, the [Morlendor](#mordenlor), **configurable** +using the `nssb.morlendor_level` parameter as negative integer: + +* If `nssb.morlendor_level` is outside of `mapgen_limit`, the mod will try to autoset best setting. +* If `nssb.morlendor_level` it overlap `nether_depth_ymax`, of nether mod, an error will raise. + +The morlendor level must be at least 320 layers of blocks over the limit, +and 1000 layers of blocks below the nether deep floor. ### New buildings diff --git a/mapgen.lua b/mapgen.lua index 28982f8..48dbaa0 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -1,4 +1,5 @@ local moreores = minetest.get_modpath("moreores") +local nethermod = minetest.get_modpath("nether") local is_50 = nssb.is_50 nssb.mymapgenis = tonumber(minetest.settings:get("mymapgenis")) or 7 @@ -6,11 +7,13 @@ if nssb.mymapgenis ~= 6 and nssb.mymapgenis ~= 7 then nssb.mymapgenis = 7 end --- get gneration level from settings +-- mapgen limits check from minetest +local mapgen_limit = tonumber(minetest.settings:get("mapgen_limit")) or 31000 + +-- get generation level from settings local level = tonumber(minetest.settings:get("nssb.morlendor_level")) or -30000 -- schematics generation - local posplace = {x = 0, y = level - 93, z = 0} local posmemory = {x = 0, y = level - 92, z = 0} local postest = {x = 5, y = level - 91, z = 6} @@ -19,6 +22,30 @@ local postest = {x = 5, y = level - 91, z = 6} local oretype_morlan_layer if is_50 then oretype_morlan_layer = "stratum" else oretype_morlan_layer = "scatter" end +-- mapgen limit must be at least enought before any check +if mapgen_limit < 400 then error("[nssb] the map limit is too low, there's no space for morlendor") end + +-- morlendor must be inside the limits, but not almost the limit of the world, and must be almost 320 levels +level_amount_and_limit = math.abs(mapgen_limit) - math.abs(level) + +while level_amount_and_limit <= 320 do + + level = (math.abs(level) - math.abs(level_amount_and_limit) - 1) * -1 + level_amount_and_limit = math.abs(mapgen_limit) - math.abs(level) + + minetest.log("error", "[nssb] incompatible morlendor level, autosetting: ".. level) +end + +-- detection of nether deep floor, mordenlor must be below more than player things, cos has industructible layer +if nethermod then + + local nether_df = math.abs(tonumber(minetest.settings:get("nether_depth_ymax")) or -11000) + + if ( math.abs(nether_df) >= math.abs(level) + 1000 ) then + error("[nssb] morlendor level conflicts with nether, unable to fix, check your settings") + end +end + function nssb_register_buildings( build, -- name of the schematic rand, -- 1/rand is the probability of the spawning of the schematic if the place found is acceptable