aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/tab_singleplayer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/mainmenu/tab_singleplayer.lua')
-rw-r--r--builtin/mainmenu/tab_singleplayer.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_singleplayer.lua
index 4ae4dde35..a40918af9 100644
--- a/builtin/mainmenu/tab_singleplayer.lua
+++ b/builtin/mainmenu/tab_singleplayer.lua
@@ -40,10 +40,13 @@ local function singleplayer_refresh_gamebar()
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.setting_get("mainmenu_last_selected_world")))
- local selected = core.get_textlist_index("sp_worlds")
if not index or index < 1 then
- index = math.min(core.get_textlist_index("sp_worlds"),
- #menudata.worldlist:get_list())
+ local selected = core.get_textlist_index("sp_worlds")
+ if selected ~= nil and selected < #menudata.worldlist:get_list() then
+ index = selected
+ else
+ index = #menudata.worldlist:get_list()
+ end
end
menu_worldmt_legacy(index)
return true