Fix attempt to start a world when no world is selected/created
authorjeanpatrick.guerrero@gmail.com <jeanpatrick.guerrero@gmail.com>
Sat, 4 Jul 2015 13:08:32 +0000 (15:08 +0200)
committerest31 <MTest31@outlook.com>
Sat, 4 Jul 2015 15:09:26 +0000 (17:09 +0200)
builtin/mainmenu/tab_singleplayer.lua

index a7fa556669340b254d5fea9c27f3ebb083bb4adb..4ae4dde3595b19977e85af0140cf931743c95763 100644 (file)
@@ -152,12 +152,14 @@ local function main_button_handler(this, fields, name, tabdata)
                world_doubleclick or
                fields["key_enter"] then
                local selected = core.get_textlist_index("sp_worlds")
+               gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
                
-               if selected ~= nil then
-                       gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
-                       gamedata.singleplayer   = true
-                       
+               if selected ~= nil and gamedata.selected_world ~= 0 then
+                       gamedata.singleplayer = true
                        core.start()
+               else
+                       gamedata.errormessage =
+                               fgettext("No world created or selected!")
                end
                return true
        end