From 23948096497c64fc1d67a4b8a2015e3b6b0289fd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 16 Jun 2020 01:46:07 +0200 Subject: [PATCH] Respect player's choice of mg_flags --- game.conf | 1 - mods/MAPGEN/mcl_mapgen_core/init.lua | 24 +++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/game.conf b/game.conf index 8c5f795e..db735770 100644 --- a/game.conf +++ b/game.conf @@ -1,3 +1,2 @@ name = MineClone 2 description = A survival sandbox game. Survive, gather, hunt, build, explore, and do much more. -disallowed_mapgen_settings = mg_flags diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 0aa192c9..afc49486 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -1077,18 +1077,32 @@ local function register_mgv6_decorations() end +local mg_flags = minetest.settings:get_flags("mg_flags") +-- Disable builtin dungeons, we provide our own dungeons +mg_flags.dungeons = false + -- Apply mapgen-specific mapgen code if mg_name == "v6" then register_mgv6_decorations() - minetest.set_mapgen_setting("mg_flags", "biomes,caves,nodungeons,decorations,light", true) elseif superflat then - -- Enforce superflat-like mapgen: No hills, lakes or caves - minetest.set_mapgen_setting("mg_flags", "biomes,nocaves,nodungeons,nodecorations,light", true) + -- Enforce superflat-like mapgen: no caves, decor, lakes and hills + mg_flags.caves = false + mg_flags.decorations = false minetest.set_mapgen_setting("mgflat_spflags", "nolakes,nohills", true) -else - minetest.set_mapgen_setting("mg_flags", "biomes,caves,nodungeons,decorations,light", true) end +local mg_flags_str = "" +for k,v in pairs(mg_flags) do + if v == false then + k = "no" .. k + end + mg_flags_str = mg_flags_str .. k .. "," +end +if string.len(mg_flags_str) > 0 then + mg_flags_str = string.sub(mg_flags_str, 1, string.len(mg_flags_str)-1) +end +minetest.set_mapgen_setting("mg_flags", mg_flags_str, true) + -- Helper function for converting a MC probability to MT, with -- regards to MapBlocks. -- Some MC generated structures are generated on per-chunk