From 4e652ea9ddb2d3d9fb2144876c7e89e2cc926f93 Mon Sep 17 00:00:00 2001 From: Muhammad Rifqi Priyo Susanto Date: Mon, 25 Dec 2017 22:11:27 +0700 Subject: [PATCH] Advanced settings: Add range check for float type --- builtin/mainmenu/dlg_settings_advanced.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.25.1