diff options
author | nOOb3167 <nOOb3167@gmail.com> | 2017-12-22 11:35:06 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2017-12-22 10:39:51 +0000 |
commit | 8037eda42c89dbc81e99199c2ae49309a9439ac3 (patch) | |
tree | f0028edd99243a4633e593993c23e0b1b4b09e5c /builtin/mainmenu | |
parent | 7354d0f3d8ea2d48a85479426bf0c055ff4926b4 (diff) | |
download | minetest-8037eda42c89dbc81e99199c2ae49309a9439ac3.tar.gz minetest-8037eda42c89dbc81e99199c2ae49309a9439ac3.tar.bz2 minetest-8037eda42c89dbc81e99199c2ae49309a9439ac3.zip |
Fix error if setting menu_last_game is not a valid game
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/dlg_create_world.lua | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 380f0654f..13061ee40 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -33,18 +33,21 @@ local function create_world_formspec(dialogdata) end end - local gamepath = core.get_game(gameidx).path - local gameconfig = Settings(gamepath.."/game.conf") - - local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split() - for key, value in pairs(disallowed_mapgens) do - disallowed_mapgens[key] = value:trim() - end + local game_by_gameidx = core.get_game(gameidx) + if game_by_gameidx ~= nil then + local gamepath = game_by_gameidx.path + local gameconfig = Settings(gamepath.."/game.conf") + + local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split() + for key, value in pairs(disallowed_mapgens) do + disallowed_mapgens[key] = value:trim() + end - if disallowed_mapgens then - for i = #mapgens, 1, -1 do - if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then - table.remove(mapgens, i) + if disallowed_mapgens then + for i = #mapgens, 1, -1 do + if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then + table.remove(mapgens, i) + end end end end |