From: Muhammad Rifqi Priyo Susanto Date: Mon, 25 Dec 2017 15:11:27 +0000 (+0700) Subject: Advanced settings: Add range check for float type X-Git-Tag: 5.0.0~664 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fpull%2F6863%2Fhead;p=oweals%2Fminetest.git Advanced settings: Add range check for float type --- diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index b784a295e..7d524eb80 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -752,6 +752,18 @@ local function handle_change_setting_buttons(this, fields) core.update_formspec(this:get_formspec()) return true end + 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