Mapgen defaults for fresh installs

A fresh install that had never had its mapgen flags tinkered with would
return nil when requesting them, which would normally mean "go with the
defaults." This mod overrides those defaults, so a fallback is needed.
This commit is contained in:
FaceDeer 2017-07-05 00:05:54 -06:00
parent 89b82ae3ad
commit 84de29259e

View File

@ -18,27 +18,43 @@ dofile(modpath.."/player_spawn.lua")
subterrane.disable_mapgen_caverns = function()
local mg_name = minetest.get_mapgen_setting("mg_name")
local flags_name
if mg_name == "v7" then flags_name = "mgv7_spflags"
elseif mg_name == "v5" then flags_name = "mgv5_spflags"
local default_flags
if mg_name == "v7" then
flags_name = "mgv7_spflags"
default_flags = "mountains,ridges,nofloatlands"
elseif mg_name == "v5" then
flags_name = "mgv5_spflags"
default_flags = ""
else
return
end
local function split(source, delimiters)
local elements = {}
local pattern = '([^'..delimiters..']+)'
string.gsub(source, pattern, function(value) elements[#elements + 1] = value; end);
return elements
end
local flags = split(minetest.get_mapgen_setting(flags_name), ", ")
local flags_setting = minetest.get_mapgen_setting(flags_name) or default_flags
local new_flags = {}
local flags = split(flags_setting, ", ")
local nocaverns_present = false
for _, flag in pairs(flags) do
if flag ~= "caverns" then
table.insert(new_flags, flag)
end
if flag == "nocaverns" then
nocaverns_present = true
end
end
if not nocaverns_present then
table.insert(new_flags, "nocaverns")
end
table.insert(new_flags, "nocaverns")
minetest.set_mapgen_setting(flags_name, table.concat(new_flags, ","), true)
end
subterrane.disable_mapgen_caverns() -- defaulting to disabling them, for now. Need to assess how to integrate this feature into subterrane better.
local c_lava = minetest.get_content_id("default:lava_source")