Skip to content

Commit

Permalink
Advanced settings: Add range check for float type
Browse files Browse the repository at this point in the history
  • Loading branch information
srifqi authored and paramat committed Dec 26, 2017
1 parent 026ad91 commit 4e652ea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions builtin/mainmenu/dlg_settings_advanced.lua
Expand Up @@ -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
Expand Down

0 comments on commit 4e652ea

Please sign in to comment.