- comment_text = fgettext_ne(setting.comment)
- 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
-
- formspec = formspec .. ";1]"
-
- if setting.type == "bool" then
- local selected_index
- 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;"
- .. fgettext("Disabled") .. "," .. fgettext("Enabled") .. ";"
- .. selected_index .. "]"
-
- elseif setting.type == "enum" then
- local selected_index = 0
- formspec = formspec .. "dropdown[0.5,3.5;3,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
- formspec = formspec .. core.formspec_escape(value) .. ","
- if get_current_value(setting) == value then
- selected_index = index
- end
- end
- if #setting.values > 0 then
- formspec = formspec:sub(1, -2) -- remove trailing comma
- end
- formspec = formspec .. ";" .. selected_index .. "]"
-
- elseif setting.type == "path" 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;;"
- .. core.formspec_escape(current_value) .. "]"
- .. "button[8,3.75;2,1;btn_browser_path;" .. fgettext("Browse") .. "]"
-
- else
- -- TODO: fancy input for float, int, flags, noise_params, v3f
- local width = 10
- 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,4;5,1;error_message;#FF0000,"
- .. core.formspec_escape(dialogdata.error_message) .. ";0]"
- width = 5
- if dialogdata.entered_text then
- text = dialogdata.entered_text
- end
- end
- formspec = formspec .. "field[0.5,4;" .. width .. ",1;te_setting_value;;"
- .. core.formspec_escape(text) .. "]"
- end
- return formspec