Update tab_singleplayer.lua

This fixes the situation where it would give you "builtin/mainmenu/tab_singleplayer.lua:167: attempt to index a nil value" where you have nothing selected (for example, switch to minimal game, delete all your old worlds, and then click the toggle buttons for creative or damage).
This commit is contained in:
poet-nohit 2015-03-26 02:59:52 -06:00
parent a082f29bd1
commit 45a87269f3
1 changed files with 18 additions and 14 deletions

View File

@ -150,6 +150,7 @@ local function main_button_handler(this, fields, name, tabdata)
if fields["cb_creative_mode"] then if fields["cb_creative_mode"] then
core.setting_set("creative_mode", fields["cb_creative_mode"]) core.setting_set("creative_mode", fields["cb_creative_mode"])
local selected = core.get_textlist_index("sp_worlds") local selected = core.get_textlist_index("sp_worlds")
if selected ~= nil then
local filename = menudata.worldlist:get_list()[selected].path .. local filename = menudata.worldlist:get_list()[selected].path ..
DIR_DELIM .. "world.mt" DIR_DELIM .. "world.mt"
@ -160,10 +161,12 @@ local function main_button_handler(this, fields, name, tabdata)
end end
return true return true
end end
end
if fields["cb_enable_damage"] then if fields["cb_enable_damage"] then
core.setting_set("enable_damage", fields["cb_enable_damage"]) core.setting_set("enable_damage", fields["cb_enable_damage"])
local selected = core.get_textlist_index("sp_worlds") local selected = core.get_textlist_index("sp_worlds")
if selected ~= nil then
local filename = menudata.worldlist:get_list()[selected].path .. local filename = menudata.worldlist:get_list()[selected].path ..
DIR_DELIM .. "world.mt" DIR_DELIM .. "world.mt"
@ -174,6 +177,7 @@ local function main_button_handler(this, fields, name, tabdata)
end end
return true return true
end end
end
if fields["play"] ~= nil or if fields["play"] ~= nil or
world_doubleclick or world_doubleclick or