summaryrefslogtreecommitdiff
path: root/builtin/mainmenu/common.lua
diff options
context:
space:
mode:
authorfz72 <fz72@gmx.de>2015-03-15 14:52:10 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-18 09:53:24 +0100
commit8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a (patch)
tree3625c1d51e16963a242c05ea1288ad70f90a5c9a /builtin/mainmenu/common.lua
parent2f0107f4a7e82019a68ae3c0572886622d9d49bf (diff)
downloadminetest-8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a.tar.gz
minetest-8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a.tar.bz2
minetest-8ca08a850ff2494652aa0ac2daa3d00f03aa4e7a.zip
Save creative_mode and enable_damage setting for each world in world.mt
Create Parameters on world initialisation and set settings of old worlds
Diffstat (limited to 'builtin/mainmenu/common.lua')
-rw-r--r--builtin/mainmenu/common.lua20
1 files changed, 19 insertions, 1 deletions
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