From 85f3d575ec3d99ef2ce680d4a2546e4d31327d83 Mon Sep 17 00:00:00 2001 From: "jeanpatrick.guerrero@gmail.com" Date: Mon, 29 Jun 2015 15:41:05 +0200 Subject: Fix bugs in mainmenu --- builtin/mainmenu/common.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'builtin/mainmenu/common.lua') 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 -- cgit v1.2.3