]> git.lizzy.rs Git - minetest.git/blobdiff - builtin/mainmenu/dlg_settings_advanced.lua
Content store: Fix update button not working
[minetest.git] / builtin / mainmenu / dlg_settings_advanced.lua
index c63eb972ec51f8f753166195859a43a7ee1d08f6..4a6fcfba7cef84d303efb0435c85dc41d1207e51 100644 (file)
@@ -25,6 +25,10 @@ local CHAR_CLASSES = {
        FLAGS = "[%w_%-%.,]",
 }
 
+local function flags_to_table(flags)
+       return flags:gsub("%s+", ""):split(",", true) -- Remove all spaces and split
+end
+
 -- returns error message, or nil
 local function parse_setting_line(settings, line, read_all, base_level, allow_secure)
        -- comment
@@ -111,7 +115,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
                return
        end
 
-       if setting_type == "string" or setting_type == "noise_params"
+       if setting_type == "string"
                        or setting_type == "key" or setting_type == "v3f" then
                local default = remaining_line:match("^(.*)$")
 
@@ -133,6 +137,60 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
                return
        end
 
+       if setting_type == "noise_params_2d"
+                       or setting_type == "noise_params_3d" then
+               local default = remaining_line:match("^(.*)$")
+
+               if not default then
+                       return "Invalid string setting"
+               end
+
+               local values = {}
+               local ti = 1
+               local index = 1
+               for line in default:gmatch("[+-]?[%d.-e]+") do -- All numeric characters
+                       index = default:find("[+-]?[%d.-e]+", index) + line:len()
+                       table.insert(values, line)
+                       ti = ti + 1
+                       if ti > 9 then
+                               break
+                       end
+               end
+               index = default:find("[^, ]", index)
+               local flags = ""
+               if index then
+                       flags = default:sub(index)
+                       default = default:sub(1, index - 3) -- Make sure no flags in single-line format
+               end
+               table.insert(values, flags)
+
+               table.insert(settings, {
+                       name = name,
+                       readable_name = readable_name,
+                       type = setting_type,
+                       default = default,
+                       default_table = {
+                               offset = values[1],
+                               scale = values[2],
+                               spread = {
+                                       x = values[3],
+                                       y = values[4],
+                                       z = values[5]
+                               },
+                               seed = values[6],
+                               octaves = values[7],
+                               persistence = values[8],
+                               lacunarity = values[9],
+                               flags = values[10]
+                       },
+                       values = values,
+                       comment = current_comment,
+                       noise_params = true,
+                       flags = flags_to_table("defaults,eased,absvalue")
+               })
+               return
+       end
+
        if setting_type == "bool" then
                if remaining_line ~= "false" and remaining_line ~= "true" then
                        return "Invalid boolean setting"
@@ -196,7 +254,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
                return
        end
 
-       if setting_type == "path" then
+       if setting_type == "path" or setting_type == "filepath" then
                local default = remaining_line:match("^(.*)$")
 
                if not default then
@@ -206,7 +264,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
                table.insert(settings, {
                        name = name,
                        readable_name = readable_name,
-                       type = "path",
+                       type = setting_type,
                        default = default,
                        comment = current_comment,
                })
@@ -236,7 +294,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
                        readable_name = readable_name,
                        type = "flags",
                        default = default,
-                       possible = possible,
+                       possible = flags_to_table(possible),
                        comment = current_comment,
                })
                return
@@ -264,7 +322,7 @@ end
 -- read_all: whether to ignore certain setting types for GUI or not
 -- parse_mods: whether to parse settingtypes.txt in mods and games
 local function parse_config_file(read_all, parse_mods)
-       local builtin_path = core.get_builtin_path() .. DIR_DELIM .. FILENAME
+       local builtin_path = core.get_builtin_path() .. FILENAME
        local file = io.open(builtin_path, "r")
        local settings = {}
        if not file then
@@ -280,7 +338,7 @@ local function parse_config_file(read_all, parse_mods)
                -- Parse games
                local games_category_initialized = false
                local index = 1
-               local game = gamemgr.get_game(index)
+               local game = pkgmgr.get_game(index)
                while game do
                        local path = game.path .. DIR_DELIM .. FILENAME
                        local file = io.open(path, "r")
@@ -307,7 +365,7 @@ local function parse_config_file(read_all, parse_mods)
                        end
 
                        index = index + 1
-                       game = gamemgr.get_game(index)
+                       game = pkgmgr.get_game(index)
                end
 
                -- Parse mods
@@ -423,74 +481,78 @@ local settings = full_settings
 local selected_setting = 1
 
 local function get_current_value(setting)
-       local value = core.setting_get(setting.name)
+       local value = core.settings:get(setting.name)
        if value == nil then
                value = setting.default
        end
        return value
 end
 
-local function create_change_setting_formspec(dialogdata)
-       local setting = settings[selected_setting]
-       local formspec = "size[10,5.2,true]" ..
-                       "button[5,4.5;2,1;btn_done;" .. fgettext("Save") .. "]" ..
-                       "button[3,4.5;2,1;btn_cancel;" .. fgettext("Cancel") .. "]" ..
-                       "tablecolumns[color;text]" ..
-                       "tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
-                       "table[0,0;10,3;info;"
-
-       if setting.readable_name then
-               formspec = formspec .. "#FFFF00," .. fgettext(setting.readable_name)
-                               .. " (" .. core.formspec_escape(setting.name) .. "),"
+local function get_current_np_group(setting)
+       local value = core.settings:get_np_group(setting.name)
+       local t = {}
+       if value == nil then
+               t = setting.values
        else
-               formspec = formspec .. "#FFFF00," .. core.formspec_escape(setting.name) .. ","
+               table.insert(t, value.offset)
+               table.insert(t, value.scale)
+               table.insert(t, value.spread.x)
+               table.insert(t, value.spread.y)
+               table.insert(t, value.spread.z)
+               table.insert(t, value.seed)
+               table.insert(t, value.octaves)
+               table.insert(t, value.persistence)
+               table.insert(t, value.lacunarity)
+               table.insert(t, value.flags)
        end
+       return t
+end
 
-       formspec = formspec .. ",,"
-
-       local comment_text = ""
-
-       if setting.comment == "" then
-               comment_text = fgettext_ne("(No description of setting given)")
+local function get_current_np_group_as_string(setting)
+       local value = core.settings:get_np_group(setting.name)
+       local t
+       if value == nil then
+               t = setting.default
        else
-               comment_text = fgettext_ne(setting.comment)
+               t = value.offset .. ", " ..
+                       value.scale .. ", (" ..
+                       value.spread.x .. ", " ..
+                       value.spread.y .. ", " ..
+                       value.spread.z .. "), " ..
+                       value.seed .. ", " ..
+                       value.octaves .. ", " ..
+                       value.persistence .. ", " ..
+                       value.lacunarity .. ", " ..
+                       value.flags
        end
-       for _, comment_line in ipairs(comment_text:split("\n", true)) do
-               formspec = formspec .. "," .. core.formspec_escape(comment_line) .. ","
-       end
-
-       if setting.type == "flags" then
-               formspec = formspec .. ",,"
-                               .. "," .. fgettext("Please enter a comma seperated list of flags.") .. ","
-                               .. "," .. fgettext("Possible values are: ")
-                               .. core.formspec_escape(setting.possible:gsub(",", ", ")) .. ","
-       elseif setting.type == "noise_params" then
-               formspec = formspec .. ",,"
-                               .. "," .. fgettext("Format: <offset>, <scale>, (<spreadX>, <spreadY>, <spreadZ>), <seed>, <octaves>, <persistence>") .. ","
-                               .. "," .. fgettext("Optionally the lacunarity can be appended with a leading comma.") .. ","
-       elseif setting.type == "v3f" then
-               formspec = formspec .. ",,"
-                               .. "," .. fgettext_ne("Format is 3 numbers separated by commas and inside brackets.") .. ","
-       end
-
-       formspec = formspec:sub(1, -2) -- remove trailing comma
+       return t
+end
 
-       formspec = formspec .. ";1]"
+local checkboxes = {} -- handle checkboxes events
 
+local function create_change_setting_formspec(dialogdata)
+       local setting = settings[selected_setting]
+       -- Final formspec will be created at the end of this function
+       -- Default values below, may be changed depending on setting type
+       local width = 10
+       local height = 3.5
+       local description_height = 3
+       local formspec = ""
+
+       -- Setting-specific formspec elements
        if setting.type == "bool" then
-               local selected_index
+               local selected_index = 1
                if core.is_yes(get_current_value(setting)) then
                        selected_index = 2
-               else
-                       selected_index = 1
                end
-               formspec = formspec .. "dropdown[0.5,3.5;3,1;dd_setting_value;"
+               formspec = "dropdown[3," .. height .. ";4,1;dd_setting_value;"
                                .. fgettext("Disabled") .. "," .. fgettext("Enabled") .. ";"
                                .. selected_index .. "]"
+               height = height + 1.25
 
        elseif setting.type == "enum" then
                local selected_index = 0
-               formspec = formspec .. "dropdown[0.5,3.5;3,1;dd_setting_value;"
+               formspec = "dropdown[3," .. height .. ";4,1;dd_setting_value;"
                for index, value in ipairs(setting.values) do
                        -- translating value is not possible, since it's the value
                        --  that we set the setting to
@@ -503,47 +565,214 @@ local function create_change_setting_formspec(dialogdata)
                        formspec = formspec:sub(1, -2) -- remove trailing comma
                end
                formspec = formspec .. ";" .. selected_index .. "]"
+               height = height + 1.25
 
-       elseif setting.type == "path" then
+       elseif setting.type == "path" or setting.type == "filepath" then
                local current_value = dialogdata.selected_path
                if not current_value then
                        current_value = get_current_value(setting)
                end
-               formspec = formspec .. "field[0.5,4;7.5,1;te_setting_value;;"
+               formspec = "field[0.28," .. height + 0.15 .. ";8,1;te_setting_value;;"
                                .. core.formspec_escape(current_value) .. "]"
-                               .. "button[8,3.75;2,1;btn_browser_path;" .. fgettext("Browse") .. "]"
+                               .. "button[8," .. height - 0.15 .. ";2,1;btn_browser_"
+                               .. setting.type .. ";" .. fgettext("Browse") .. "]"
+               height = height + 1.15
+
+       elseif setting.type == "noise_params_2d" or setting.type == "noise_params_3d" then
+               local t = get_current_np_group(setting)
+               local dimension = 3
+               if setting.type == "noise_params_2d" then
+                       dimension = 2
+               end
+
+               -- More space for 3x3 fields
+               description_height = description_height - 1.5
+               height = height - 1.5
+
+               local fields = {}
+               local function add_field(x, name, label, value)
+                       fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format(
+                               x, height, name, label, core.formspec_escape(value or "")
+                       )
+               end
+               -- First row
+               height = height + 0.3
+               add_field(0.3, "te_offset", "Offset", t[1])
+               add_field(3.6, "te_scale",  "Scale",  t[2])
+               add_field(6.9, "te_seed",   "Seed",   t[6])
+               height = height + 1.1
+
+               -- Second row
+               add_field(0.3, "te_spreadx", "X spread", t[3])
+               if dimension == 3 then
+                       add_field(3.6, "te_spready", "Y spread", t[4])
+               else
+                       fields[#fields + 1] = "label[4," .. height - 0.2 .. ";2D Noise]"
+               end
+               add_field(6.9, "te_spreadz", "Z spread", t[5])
+               height = height + 1.1
+
+               -- Third row
+               add_field(0.3, "te_octaves", "Octaves",     t[7])
+               add_field(3.6, "te_persist", "Persistance", t[8])
+               add_field(6.9, "te_lacun",   "Lacunarity",  t[9])
+               height = height + 1.1
+
+
+               local enabled_flags = flags_to_table(t[10])
+               local flags = {}
+               for _, name in ipairs(enabled_flags) do
+                       -- Index by name, to avoid iterating over all enabled_flags for every possible flag.
+                       flags[name] = true
+               end
+               for _, name in ipairs(setting.flags) do
+                       local checkbox_name = "cb_" .. name
+                       local is_enabled = flags[name] == true -- to get false if nil
+                       checkboxes[checkbox_name] = is_enabled
+               end
+               -- Flags
+               formspec = table.concat(fields)
+                               .. "checkbox[0.5," .. height - 0.6 .. ";cb_defaults;defaults;" -- defaults
+                               .. tostring(flags["defaults"] == true) .. "]" -- to get false if nil
+                               .. "checkbox[5," .. height - 0.6 .. ";cb_eased;eased;" -- eased
+                               .. tostring(flags["eased"] == true) .. "]"
+                               .. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;absvalue;" -- absvalue
+                               .. tostring(flags["absvalue"] == true) .. "]"
+               height = height + 1
+
+       elseif setting.type == "v3f" then
+               local val = get_current_value(setting)
+               local v3f = {}
+               for line in val:gmatch("[+-]?[%d.-e]+") do -- All numeric characters
+                       table.insert(v3f, line)
+               end
+
+               height = height + 0.3
+               formspec = formspec
+                               .. "field[0.3," .. height .. ";3.3,1;te_x;X;" -- X
+                               .. core.formspec_escape(v3f[1] or "") .. "]"
+                               .. "field[3.6," .. height .. ";3.3,1;te_y;Y;" -- Y
+                               .. core.formspec_escape(v3f[2] or "") .. "]"
+                               .. "field[6.9," .. height .. ";3.3,1;te_z;Z;" -- Z
+                               .. core.formspec_escape(v3f[3] or "") .. "]"
+               height = height + 1.1
+
+       elseif setting.type == "flags" then
+               local enabled_flags = flags_to_table(get_current_value(setting))
+               local flags = {}
+               for _, name in ipairs(enabled_flags) do
+                       -- Index by name, to avoid iterating over all enabled_flags for every possible flag.
+                       flags[name] = true
+               end
+               local flags_count = #setting.possible
+               local max_height = flags_count / 4
+
+               -- More space for flags
+               description_height = description_height - 1
+               height = height - 1
+
+               local fields = {} -- To build formspec
+               for i, name in ipairs(setting.possible) do
+                       local x = 0.5
+                       local y = height + i / 2 - 0.75
+                       if i - 1 >= flags_count / 2 then -- 2nd column
+                               x = 5
+                               y = y - max_height
+                       end
+                       local checkbox_name = "cb_" .. name
+                       local is_enabled = flags[name] == true -- to get false if nil
+                       checkboxes[checkbox_name] = is_enabled
+
+                       fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
+                               x, y, checkbox_name, name, tostring(is_enabled)
+                       )
+               end
+               formspec = table.concat(fields)
+               height = height + max_height + 0.25
 
        else
-               -- TODO: fancy input for float, int, flags, noise_params, v3f
-               local width = 10
+               -- TODO: fancy input for float, int
                local text = get_current_value(setting)
-               if dialogdata.error_message then
-                       formspec = formspec .. "tablecolumns[color;text]" ..
-                       "tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
-                       "table[5,3.9;5,0.6;error_message;#FF0000,"
-                                       .. core.formspec_escape(dialogdata.error_message) .. ";0]"
-                       width = 5
-                       if dialogdata.entered_text then
-                               text = dialogdata.entered_text
-                       end
+               if dialogdata.error_message and dialogdata.entered_text then
+                       text = dialogdata.entered_text
                end
-               formspec = formspec .. "field[0.5,4;" .. width .. ",1;te_setting_value;;"
+               formspec = "field[0.28," .. height + 0.15 .. ";" .. width .. ",1;te_setting_value;;"
                                .. core.formspec_escape(text) .. "]"
+               height = height + 1.15
        end
-       return formspec
+
+       -- Box good, textarea bad. Calculate textarea size from box.
+       local function create_textfield(size, label, text, bg_color)
+               local textarea = {
+                       x = size.x + 0.3,
+                       y = size.y,
+                       w = size.w + 0.25,
+                       h = size.h * 1.16 + 0.12
+               }
+               return ("box[%f,%f;%f,%f;%s]textarea[%f,%f;%f,%f;;%s;%s]"):format(
+                       size.x, size.y, size.w, size.h, bg_color or "#000",
+                       textarea.x, textarea.y, textarea.w, textarea.h,
+                       core.formspec_escape(label), core.formspec_escape(text)
+               )
+
+       end
+
+       -- When there's an error: Shrink description textarea and add error below
+       if dialogdata.error_message then
+               local error_box = {
+                       x = 0,
+                       y = description_height - 0.4,
+                       w = width - 0.25,
+                       h = 0.5
+               }
+               formspec = formspec ..
+                       create_textfield(error_box, "", dialogdata.error_message, "#600")
+               description_height = description_height - 0.75
+       end
+
+       -- Get description field
+       local description_box = {
+               x = 0,
+               y = 0.2,
+               w = width - 0.25,
+               h = description_height
+       }
+
+       local setting_name = setting.name
+       if setting.readable_name then
+               setting_name = fgettext_ne(setting.readable_name) ..
+                       " (" .. setting.name .. ")"
+       end
+
+       local comment_text = ""
+       if setting.comment == "" then
+               comment_text = fgettext_ne("(No description of setting given)")
+       else
+               comment_text = fgettext_ne(setting.comment)
+       end
+
+       return (
+               "size[" .. width .. "," .. height + 0.25 .. ",true]" ..
+               create_textfield(description_box, setting_name, comment_text) ..
+               formspec ..
+               "button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" ..
+                       fgettext("Save") .. "]" ..
+               "button[" .. width / 2 .. "," .. height - 0.4 .. ";2.5,1;btn_cancel;" ..
+                       fgettext("Cancel") .. "]"
+       )
 end
 
 local function handle_change_setting_buttons(this, fields)
+       local setting = settings[selected_setting]
        if fields["btn_done"] or fields["key_enter"] then
-               local setting = settings[selected_setting]
                if setting.type == "bool" then
                        local new_value = fields["dd_setting_value"]
                        -- Note: new_value is the actual (translated) value shown in the dropdown
-                       core.setting_setbool(setting.name, new_value == fgettext("Enabled"))
+                       core.settings:set_bool(setting.name, new_value == fgettext("Enabled"))
 
                elseif setting.type == "enum" then
                        local new_value = fields["dd_setting_value"]
-                       core.setting_set(setting.name, new_value)
+                       core.settings:set(setting.name, new_value)
 
                elseif setting.type == "int" then
                        local new_value = tonumber(fields["te_setting_value"])
@@ -565,7 +794,7 @@ local function handle_change_setting_buttons(this, fields)
                                core.update_formspec(this:get_formspec())
                                return true
                        end
-                       core.setting_set(setting.name, new_value)
+                       core.settings:set(setting.name, new_value)
 
                elseif setting.type == "float" then
                        local new_value = tonumber(fields["te_setting_value"])
@@ -575,27 +804,74 @@ local function handle_change_setting_buttons(this, fields)
                                core.update_formspec(this:get_formspec())
                                return true
                        end
-                       core.setting_set(setting.name, new_value)
+                       if setting.min and new_value < setting.min then
+                               this.data.error_message = fgettext_ne("The value must be at least $1.", setting.min)
+                               this.data.entered_text = fields["te_setting_value"]
+                               core.update_formspec(this:get_formspec())
+                               return true
+                       end
+                       if setting.max and new_value > setting.max then
+                               this.data.error_message = fgettext_ne("The value must not be larger than $1.", setting.max)
+                               this.data.entered_text = fields["te_setting_value"]
+                               core.update_formspec(this:get_formspec())
+                               return true
+                       end
+                       core.settings:set(setting.name, new_value)
 
                elseif setting.type == "flags" then
-                       local new_value = fields["te_setting_value"]
-                       for _,value in ipairs(new_value:split(",", true)) do
-                               value = value:trim()
-                               local possible = "," .. setting.possible .. ","
-                               if not possible:find("," .. value .. ",", 0, true) then
-                                       this.data.error_message = fgettext_ne("\"$1\" is not a valid flag.", value)
-                                       this.data.entered_text = fields["te_setting_value"]
-                                       core.update_formspec(this:get_formspec())
-                                       return true
+                       local values = {}
+                       for _, name in ipairs(setting.possible) do
+                               if checkboxes["cb_" .. name] then
+                                       table.insert(values, name)
+                               end
+                       end
+
+                       checkboxes = {}
+
+                       local new_value = table.concat(values, ", ")
+                       core.settings:set(setting.name, new_value)
+
+               elseif setting.type == "noise_params_2d" or setting.type == "noise_params_3d" then
+                       local np_flags = {}
+                       for _, name in ipairs(setting.flags) do
+                               if checkboxes["cb_" .. name] then
+                                       table.insert(np_flags, name)
                                end
                        end
-                       core.setting_set(setting.name, new_value)
+
+                       checkboxes = {}
+
+                       if setting.type == "noise_params_2d" then
+                                fields["te_spready"] = fields["te_spreadz"]
+                       end
+                       local new_value = {
+                               offset = fields["te_offset"],
+                               scale = fields["te_scale"],
+                               spread = {
+                                       x = fields["te_spreadx"],
+                                       y = fields["te_spready"],
+                                       z = fields["te_spreadz"]
+                               },
+                               seed = fields["te_seed"],
+                               octaves = fields["te_octaves"],
+                               persistence = fields["te_persist"],
+                               lacunarity = fields["te_lacun"],
+                               flags = table.concat(np_flags, ", ")
+                       }
+                       core.settings:set_np_group(setting.name, new_value)
+
+               elseif setting.type == "v3f" then
+                       local new_value = "("
+                                       .. fields["te_x"] .. ", "
+                                       .. fields["te_y"] .. ", "
+                                       .. fields["te_z"] .. ")"
+                       core.settings:set(setting.name, new_value)
 
                else
                        local new_value = fields["te_setting_value"]
-                       core.setting_set(setting.name, new_value)
+                       core.settings:set(setting.name, new_value)
                end
-               core.setting_save()
+               core.settings:write()
                this:delete()
                return true
        end
@@ -606,7 +882,13 @@ local function handle_change_setting_buttons(this, fields)
        end
 
        if fields["btn_browser_path"] then
-               core.show_file_open_dialog("dlg_browse_path", fgettext_ne("Select path"))
+               core.show_path_select_dialog("dlg_browse_path",
+                       fgettext_ne("Select directory"), false)
+       end
+
+       if fields["btn_browser_filepath"] then
+               core.show_path_select_dialog("dlg_browse_path",
+                       fgettext_ne("Select file"), true)
        end
 
        if fields["dlg_browse_path_accepted"] then
@@ -614,22 +896,32 @@ local function handle_change_setting_buttons(this, fields)
                core.update_formspec(this:get_formspec())
        end
 
+       if setting.type == "flags"
+                       or setting.type == "noise_params_2d"
+                       or setting.type == "noise_params_3d" then
+               for name, value in pairs(fields) do
+                       if name:sub(1, 3) == "cb_" then
+                               checkboxes[name] = value == "true"
+                       end
+               end
+       end
+
        return false
 end
 
 local function create_settings_formspec(tabview, name, tabdata)
-       local formspec = "size[12,6.5;true]" ..
-                       "tablecolumns[color;tree;text,width=32;text]" ..
+       local formspec = "size[12,5.4;true]" ..
+                       "tablecolumns[color;tree;text,width=28;text]" ..
                        "tableoptions[background=#00000000;border=false]" ..
                        "field[0.3,0.1;10.2,1;search_string;;" .. core.formspec_escape(search_string) .. "]" ..
                        "field_close_on_enter[search_string;false]" ..
                        "button[10.2,-0.2;2,1;search;" .. fgettext("Search") .. "]" ..
-                       "table[0,0.8;12,4.5;list_settings;"
+                       "table[0,0.8;12,3.5;list_settings;"
 
        local current_level = 0
        for _, entry in ipairs(settings) do
                local name
-               if not core.setting_getbool("main_menu_technical_settings") and entry.readable_name then
+               if not core.settings:get_bool("main_menu_technical_settings") and entry.readable_name then
                        name = fgettext_ne(entry.readable_name)
                else
                        name = entry.name
@@ -652,6 +944,10 @@ local function create_settings_formspec(tabview, name, tabdata)
                elseif entry.type == "key" then
                        -- ignore key settings, since we have a special dialog for them
 
+               elseif entry.type == "noise_params_2d" or entry.type == "noise_params_3d" then
+                       formspec = formspec .. "," .. (current_level + 1) .. "," .. core.formspec_escape(name) .. ","
+                                       .. core.formspec_escape(get_current_np_group_as_string(entry)) .. ","
+
                else
                        formspec = formspec .. "," .. (current_level + 1) .. "," .. core.formspec_escape(name) .. ","
                                        .. core.formspec_escape(get_current_value(entry)) .. ","
@@ -662,11 +958,11 @@ local function create_settings_formspec(tabview, name, tabdata)
                formspec = formspec:sub(1, -2) -- remove trailing comma
        end
        formspec = formspec .. ";" .. selected_setting .. "]" ..
-                       "button[0,6;4,1;btn_back;".. fgettext("< Back to Settings page") .. "]" ..
-                       "button[10,6;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
-                       "button[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
-                       "checkbox[0,5.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
-                                       .. dump(core.setting_getbool("main_menu_technical_settings")) .. "]"
+                       "button[0,4.9;4,1;btn_back;".. fgettext("< Back to Settings page") .. "]" ..
+                       "button[10,4.9;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
+                       "button[7,4.9;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
+                       "checkbox[0,4.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
+                                       .. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]"
 
        return formspec
 end
@@ -680,8 +976,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
                        local setting = settings[selected_setting]
                        if setting and setting.type == "bool" then
                                local current_value = get_current_value(setting)
-                               core.setting_setbool(setting.name, not core.is_yes(current_value))
-                               core.setting_save()
+                               core.settings:set_bool(setting.name, not core.is_yes(current_value))
+                               core.settings:write()
                                return true
                        else
                                list_enter = true
@@ -736,8 +1032,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
        if fields["btn_restore"] then
                local setting = settings[selected_setting]
                if setting and setting.type ~= "category" then
-                       core.setting_set(setting.name, setting.default)
-                       core.setting_save()
+                       core.settings:remove(setting.name)
+                       core.settings:write()
                        core.update_formspec(this:get_formspec())
                end
                return true
@@ -749,8 +1045,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
        end
 
        if fields["cb_tech_settings"] then
-               core.setting_set("main_menu_technical_settings", fields["cb_tech_settings"])
-               core.setting_save()
+               core.settings:set("main_menu_technical_settings", fields["cb_tech_settings"])
+               core.settings:write()
                core.update_formspec(this:get_formspec())
                return true
        end
@@ -767,6 +1063,7 @@ function create_adv_settings_dlg()
                                return dlg
 end
 
--- Generate minetest.conf.example and settings_translation_file.cpp
+-- Uncomment to generate minetest.conf.example and settings_translation_file.cpp
+-- For RUN_IN_PLACE the generated files may appear in the bin folder
 
---assert(loadfile(core.get_builtin_path()..DIR_DELIM.."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false))
+--assert(loadfile(core.get_builtin_path().."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false))