aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>2017-12-25 22:11:27 +0700
committerparamat <mat.gregory@virginmedia.com>2017-12-26 21:55:58 +0000
commit4e652ea9ddb2d3d9fb2144876c7e89e2cc926f93 (patch)
tree0e1516f016824727deba54c47a3817dcb0bc45da
parent026ad912af0ad147071da79201a335ec84bd6ce9 (diff)
downloadminetest-4e652ea9ddb2d3d9fb2144876c7e89e2cc926f93.tar.gz
minetest-4e652ea9ddb2d3d9fb2144876c7e89e2cc926f93.tar.bz2
minetest-4e652ea9ddb2d3d9fb2144876c7e89e2cc926f93.zip
Advanced settings: Add range check for float type
-rw-r--r--builtin/mainmenu/dlg_settings_advanced.lua12
1 files changed, 12 insertions, 0 deletions
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