From a7436a3bd4202bde4885d20a1775418dba595318 Mon Sep 17 00:00:00 2001 From: nOOb3167 Date: Fri, 22 Dec 2017 11:35:06 +0100 Subject: [PATCH] Fix error if setting menu_last_game is not a valid game --- builtin/mainmenu/dlg_create_world.lua | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 380f065..13061ee 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 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 + 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