moremesecons.setting: remove pointless val_under_min parameter

This commit is contained in:
upsilon 2017-04-19 18:33:36 +02:00
parent ea81d826b9
commit b60a719b14
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C

View File

@ -1,6 +1,6 @@
moremesecons = {} moremesecons = {}
function moremesecons.setting(modname, settingname, default, min, val_under_min) function moremesecons.setting(modname, settingname, default, min)
local setting = "moremesecons_" .. modname .. "." .. settingname local setting = "moremesecons_" .. modname .. "." .. settingname
if type(default) == "boolean" then if type(default) == "boolean" then
@ -14,14 +14,12 @@ function moremesecons.setting(modname, settingname, default, min, val_under_min)
elseif type(default) == "number" then elseif type(default) == "number" then
local ret = tonumber(minetest.setting_get(setting)) or default local ret = tonumber(minetest.setting_get(setting)) or default
if ret ~= ret then -- NaN if ret ~= ret then -- NaN
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is NaN. Set to default value "..tostring(default)..".") minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is NaN. Set to default value ("..tostring(default)..").")
ret = default ret = default
end end
if min then if min and ret < min then
if ret < min then minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is under minimum value "..tostring(min)..". Set to minimum value ("..tostring(min)..").")
minetest.log("warning", "[moremesecons_"..modname.."]: setting '"..setting.."' is under minimum value "..tostring(min)..". Set to "..tostring(val_under_min or min)..".") ret = min
ret = val_under_min or min
end
end end
return ret return ret
end end