aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-22 10:22:25 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-25 09:08:17 +0100
commit284fefb0c32e8222fadd78eeec6e7e718fe25668 (patch)
tree5c4cf29dabcf1ce59b4bdac973f966988f3aef2f
parentb711d9040ff392222516ba6aabe4a5ace9fc260d (diff)
downloadminetest-284fefb0c32e8222fadd78eeec6e7e718fe25668.tar.gz
minetest-284fefb0c32e8222fadd78eeec6e7e718fe25668.tar.bz2
minetest-284fefb0c32e8222fadd78eeec6e7e718fe25668.zip
Remove duplicate code since 8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a
-rw-r--r--builtin/mainmenu/common.lua31
1 files changed, 14 insertions, 17 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua
index c1e8ee9c4..d6e2588fa 100644
--- a/builtin/mainmenu/common.lua
+++ b/builtin/mainmenu/common.lua
@@ -40,6 +40,18 @@ local function render_client_count(n)
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)
return "image," ..
@@ -197,15 +209,7 @@ function menu_handle_key_up_down(fields,textlist,settingname)
core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx))
- local worldconfig = modmgr.get_worldconfig(
- 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
+ configure_selected_world_params(newidx)
end
return true
end
@@ -217,15 +221,8 @@ function menu_handle_key_up_down(fields,textlist,settingname)
local newidx = oldidx + 1
core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx))
- local worldconfig = modmgr.get_worldconfig(
- 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
+ configure_selected_world_params(newidx)
end
return true