From 8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a Mon Sep 17 00:00:00 2001 From: fz72 Date: Sun, 15 Mar 2015 14:52:10 +0100 Subject: Save creative_mode and enable_damage setting for each world in world.mt Create Parameters on world initialisation and set settings of old worlds --- builtin/mainmenu/common.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'builtin/mainmenu/common.lua') diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index f32d77f2a..c1e8ee9c4 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -189,7 +189,6 @@ end -------------------------------------------------------------------------------- function menu_handle_key_up_down(fields,textlist,settingname) - if fields["key_up"] then local oldidx = core.get_textlist_index(textlist) @@ -197,6 +196,16 @@ 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 end return true end @@ -208,6 +217,15 @@ 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 end return true -- cgit v1.2.3