Skip to content

Commit f91124a

Browse files
authoredApr 6, 2020
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.
1 parent faedde0 commit f91124a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎builtin/mainmenu/dlg_create_world.lua

+13
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,24 @@ local function create_world_formspec(dialogdata)
3939
local gamepath = game_by_gameidx.path
4040
local gameconfig = Settings(gamepath.."/game.conf")
4141

42+
local allowed_mapgens = (gameconfig:get("allowed_mapgens") or ""):split()
43+
for key, value in pairs(allowed_mapgens) do
44+
allowed_mapgens[key] = value:trim()
45+
end
46+
4247
local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split()
4348
for key, value in pairs(disallowed_mapgens) do
4449
disallowed_mapgens[key] = value:trim()
4550
end
4651

52+
if #allowed_mapgens > 0 then
53+
for i = #mapgens, 1, -1 do
54+
if table.indexof(allowed_mapgens, mapgens[i]) == -1 then
55+
table.remove(mapgens, i)
56+
end
57+
end
58+
end
59+
4760
if disallowed_mapgens then
4861
for i = #mapgens, 1, -1 do
4962
if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then

‎doc/lua_api.txt

+8
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ The game directory can contain the following files:
6464
* `game.conf`, with the following keys:
6565
* `name`: Required, human readable name e.g. `name = Minetest`
6666
* `description`: Short description to be shown in the content tab
67+
* `allowed_mapgens = <comma-separated mapgens>`
68+
e.g. `allowed_mapgens = v5,v6,flat`
69+
Mapgens not in this list are removed from the list of mapgens for
70+
the game.
71+
If not specified, all mapgens are allowed.
6772
* `disallowed_mapgens = <comma-separated mapgens>`
6873
e.g. `disallowed_mapgens = v5,v6,flat`
6974
These mapgens are removed from the list of mapgens for the game.
75+
When both `allowed_mapgens` and `disallowed_mapgens` are
76+
specified, `allowed_mapgens` is applied before
77+
`disallowed_mapgens`.
7078
* `minetest.conf`:
7179
Used to set default settings when running this game.
7280
* `settingtypes.txt`:

0 commit comments

Comments
 (0)
Please sign in to comment.