Skip to content

Commit 4e652ea

Browse files
srifqiparamat
authored andcommittedDec 26, 2017
Advanced settings: Add range check for float type
1 parent 026ad91 commit 4e652ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎builtin/mainmenu/dlg_settings_advanced.lua

+12
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,18 @@ local function handle_change_setting_buttons(this, fields)
752752
core.update_formspec(this:get_formspec())
753753
return true
754754
end
755+
if setting.min and new_value < setting.min then
756+
this.data.error_message = fgettext_ne("The value must be at least $1.", setting.min)
757+
this.data.entered_text = fields["te_setting_value"]
758+
core.update_formspec(this:get_formspec())
759+
return true
760+
end
761+
if setting.max and new_value > setting.max then
762+
this.data.error_message = fgettext_ne("The value must not be larger than $1.", setting.max)
763+
this.data.entered_text = fields["te_setting_value"]
764+
core.update_formspec(this:get_formspec())
765+
return true
766+
end
755767
core.settings:set(setting.name, new_value)
756768

757769
elseif setting.type == "flags" then

0 commit comments

Comments
 (0)
Please sign in to comment.