Remove duplicate code since 8ca08a850f

stable-0.4
Loic Blot 2015-03-22 10:22:25 +01:00
parent b711d9040f
commit 284fefb0c3
1 changed files with 14 additions and 17 deletions

View File

@ -40,6 +40,18 @@ local function render_client_count(n)
end end
end end
local function configure_selected_world_params(idx)
local worldconfig = modmgr.get_worldconfig(
menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode ~= nil then
core.setting_set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage ~= nil then
core.setting_set("enable_damage", worldconfig.enable_damage)
end
end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function image_column(tooltip, flagname) function image_column(tooltip, flagname)
return "image," .. return "image," ..
@ -197,15 +209,7 @@ function menu_handle_key_up_down(fields,textlist,settingname)
core.setting_set(settingname, core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx)) menudata.worldlist:get_raw_index(newidx))
local worldconfig = modmgr.get_worldconfig( configure_selected_world_params(newidx)
menudata.worldlist:get_list()[newidx].path)
if worldconfig.creative_mode ~= nil then
core.setting_set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage ~= nil then
core.setting_set("enable_damage", worldconfig.enable_damage)
end
end end
return true return true
end end
@ -217,15 +221,8 @@ function menu_handle_key_up_down(fields,textlist,settingname)
local newidx = oldidx + 1 local newidx = oldidx + 1
core.setting_set(settingname, core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx)) menudata.worldlist:get_raw_index(newidx))
local worldconfig = modmgr.get_worldconfig(
menudata.worldlist:get_list()[newidx].path)
if worldconfig.creative_mode ~= nil then configure_selected_world_params(newidx)
core.setting_set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage ~= nil then
core.setting_set("enable_damage", worldconfig.enable_damage)
end
end end
return true return true