diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-19 17:03:41 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-19 17:03:41 +0200 |
commit | f69524e8bfb862a470ca8bdd0c2d6df9cee8ccce (patch) | |
tree | 93baa222531c8b7694a46e9d1700c3adc30fab80 /src | |
parent | 5aee90eca42e15fd67068cb7973c1547f8d44eca (diff) | |
download | lanes-f69524e8bfb862a470ca8bdd0c2d6df9cee8ccce.tar.gz lanes-f69524e8bfb862a470ca8bdd0c2d6df9cee8ccce.tar.bz2 lanes-f69524e8bfb862a470ca8bdd0c2d6df9cee8ccce.zip |
Boyscouting
Diffstat (limited to 'src')
-rw-r--r-- | src/lanes.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lanes.lua b/src/lanes.lua index 3ed4e4e..95d3bd3 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -184,37 +184,37 @@ local param_checkers = | |||
184 | 184 | ||
185 | -- ################################################################################################# | 185 | -- ################################################################################################# |
186 | 186 | ||
187 | local params_checker = function(settings_) | 187 | local params_checker = function(user_settings_) |
188 | if not settings_ then | 188 | if not user_settings_ then |
189 | return default_params | 189 | return default_params |
190 | end | 190 | end |
191 | -- make a copy of the table to leave the provided one unchanged, *and* to help ensure it won't change behind our back | 191 | -- make a copy of the table to leave the provided one unchanged, *and* to help ensure it won't change behind our back |
192 | local settings = {} | 192 | local _compound_settings = {} |
193 | if type(settings_) ~= "table" then | 193 | if type(user_settings_) ~= "table" then |
194 | error "Bad argument #1 to lanes.configure(), should be a table" | 194 | error "Bad argument #1 to lanes.configure(), should be a table" |
195 | end | 195 | end |
196 | -- any setting unknown to Lanes raises an error | 196 | -- any setting unknown to Lanes raises an error |
197 | for setting, _ in pairs(settings_) do | 197 | for _setting, _ in pairs(user_settings_) do |
198 | if not param_checkers[setting] then | 198 | if not param_checkers[_setting] then |
199 | error("Unknown argument '" .. setting .. "' in configure options") | 199 | error("Unknown parameter '" .. _setting .. "' in configure options") |
200 | end | 200 | end |
201 | end | 201 | end |
202 | -- any setting not present in the provided parameters takes the default value | 202 | -- any setting not present in the provided parameters takes the default value |
203 | for key, checker in pairs(param_checkers) do | 203 | for _key, _checker in pairs(param_checkers) do |
204 | local my_param = settings_[key] | 204 | local my_param = user_settings_[_key] |
205 | local param | 205 | local param |
206 | if my_param ~= nil then | 206 | if my_param ~= nil then |
207 | param = my_param | 207 | param = my_param |
208 | else | 208 | else |
209 | param = default_params[key] | 209 | param = default_params[_key] |
210 | end | 210 | end |
211 | local _result, _msg = checker(param) | 211 | local _result, _msg = _checker(param) |
212 | if not _result then | 212 | if not _result then |
213 | error("Bad argument " .. key .. ": " .. tostring(param) .. (_msg and " (" .. _msg .. ")" or ""), 2) | 213 | error("Bad parameter " .. _key .. ": " .. tostring(param) .. (_msg and " (" .. _msg .. ")" or ""), 2) |
214 | end | 214 | end |
215 | settings[key] = param | 215 | _compound_settings[_key] = param |
216 | end | 216 | end |
217 | return settings | 217 | return _compound_settings |
218 | end | 218 | end |
219 | 219 | ||
220 | -- ################################################################################################# | 220 | -- ################################################################################################# |