diff options
author | jeanpatrick.guerrero@gmail.com <jeanpatrick.guerrero@gmail.com> | 2015-06-29 15:41:05 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-30 18:11:38 +0200 |
commit | 85f3d575ec3d99ef2ce680d4a2546e4d31327d83 (patch) | |
tree | dd67dd7c312cc05351e31082534efb204325e7d5 /builtin/mainmenu/common.lua | |
parent | 91f95fd4df82645e23a9734795d11ec9b8e522f8 (diff) | |
download | minetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.tar.gz minetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.tar.bz2 minetest-85f3d575ec3d99ef2ce680d4a2546e4d31327d83.zip |
Fix bugs in mainmenu
Diffstat (limited to 'builtin/mainmenu/common.lua')
-rw-r--r-- | builtin/mainmenu/common.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 6126c61a4..bcb075f99 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -300,3 +300,34 @@ function is_server_protocol_compat_or_error(proto_min, proto_max) return true end +-------------------------------------------------------------------------------- +function menu_worldmt(selected, setting, value) + local world = menudata.worldlist:get_list()[selected] + if world then + local filename = world.path .. DIR_DELIM .. "world.mt" + local world_conf = Settings(filename) + + if value then + if not world_conf:write() then + core.log("error", "Failed to write world config file") + end + return world_conf:set(setting, value) + else + return world_conf:get(setting) + end + else + return nil + end +end + +function menu_worldmt_legacy() + local modes = {"creative_mode", "enable_damage"} + for _, mode in pairs(modes) do + local mode = menu_worldmt(selected, ""..mode.."") + if mode then + core.setting_set(""..mode.."", mode) + else + menu_worldmt(selected, ""..mode.."", core.setting_get(""..mode.."")) + end + end +end |