diff options
author | Wren Turkal <wt@penguintechs.org> | 2020-04-06 07:06:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 16:06:16 +0200 |
commit | f91124a0c0d8c448b3d3d0767b3c8b2352c92d6e (patch) | |
tree | 6dac4ff308edcedecb8efe88f9cfcb6fe968b35d /builtin/mainmenu | |
parent | faedde08f96b671078d9d3273da468db3454713c (diff) | |
download | minetest-f91124a0c0d8c448b3d3d0767b3c8b2352c92d6e.tar.gz minetest-f91124a0c0d8c448b3d3d0767b3c8b2352c92d6e.tar.bz2 minetest-f91124a0c0d8c448b3d3d0767b3c8b2352c92d6e.zip |
Add allowed_mapgens option in game.conf. (#9263)
The game.conf has a disallowed_mapgens option. However, some games
require a certain mapgen to be used, like the CTF plugin. This change
adds an option to specify allowed mapgens so that the setting can be
specified in a way that needn't be updated as map generators are added
to Minetest.
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/dlg_create_world.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 31d41d693..f28ae6960 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -39,11 +39,24 @@ local function create_world_formspec(dialogdata) local gamepath = game_by_gameidx.path local gameconfig = Settings(gamepath.."/game.conf") + local allowed_mapgens = (gameconfig:get("allowed_mapgens") or ""):split() + for key, value in pairs(allowed_mapgens) do + allowed_mapgens[key] = value:trim() + end + local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split() for key, value in pairs(disallowed_mapgens) do disallowed_mapgens[key] = value:trim() end + if #allowed_mapgens > 0 then + for i = #mapgens, 1, -1 do + if table.indexof(allowed_mapgens, mapgens[i]) == -1 then + table.remove(mapgens, i) + end + end + end + if disallowed_mapgens then for i = #mapgens, 1, -1 do if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then |