lualoader: Simplify some expressions
- No need for a 'goto' when our entire loop body is then wrapped in a conditional. - No need to leave commented out prints laying around - If an expression is clearly going to be either nil or an expression that isn't likely to be a boolean, we might as well use `or` to specify a default value for the expression. e.g. `loader.getenv(...) or "no"`
This commit is contained in:
parent
9994e26f37
commit
8d21763e08
@ -205,10 +205,7 @@ local function loadModule(mod, silent)
|
|||||||
local status = true
|
local status = true
|
||||||
local pstatus
|
local pstatus
|
||||||
for k, v in pairs(mod) do
|
for k, v in pairs(mod) do
|
||||||
if v.load == nil then
|
if v.load ~= nil and v.load:lower() == "yes" then
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
if v.load:lower() == "yes" then
|
|
||||||
local str = "load "
|
local str = "load "
|
||||||
if v.flags ~= nil then
|
if v.flags ~= nil then
|
||||||
str = str .. v.flags .. " "
|
str = str .. v.flags .. " "
|
||||||
@ -247,12 +244,7 @@ local function loadModule(mod, silent)
|
|||||||
status = status and pstatus
|
status = status and pstatus
|
||||||
end
|
end
|
||||||
|
|
||||||
-- else
|
|
||||||
-- if not silent then
|
|
||||||
-- print("Skipping module '". . k .. "'")
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return status
|
return status
|
||||||
@ -272,11 +264,8 @@ local function readFile(name, silent)
|
|||||||
-- We might have read in the whole file, this won't be needed any more.
|
-- We might have read in the whole file, this won't be needed any more.
|
||||||
io.close(f)
|
io.close(f)
|
||||||
|
|
||||||
if text == nil then
|
if text == nil and not silent then
|
||||||
if not silent then
|
print(MSG_FAILREADCFG:format(name))
|
||||||
print(MSG_FAILREADCFG:format(name))
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
@ -322,11 +311,7 @@ config.verbose = false
|
|||||||
|
|
||||||
-- The first item in every carousel is always the default item.
|
-- The first item in every carousel is always the default item.
|
||||||
function config.getCarouselIndex(id)
|
function config.getCarouselIndex(id)
|
||||||
local val = carousel_choices[id]
|
return carousel_choices[id] or 1
|
||||||
if val == nil then
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
return val
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function config.setCarouselIndex(id, idx)
|
function config.setCarouselIndex(id, idx)
|
||||||
@ -498,10 +483,7 @@ function config.load(file)
|
|||||||
|
|
||||||
-- Cache the provided module_path at load time for later use
|
-- Cache the provided module_path at load time for later use
|
||||||
config.module_path = loader.getenv("module_path")
|
config.module_path = loader.getenv("module_path")
|
||||||
local verbose = loader.getenv("verbose_loading")
|
local verbose = loader.getenv("verbose_loading") or "no"
|
||||||
if verbose == nil then
|
|
||||||
verbose = "no"
|
|
||||||
end
|
|
||||||
config.verbose = verbose:lower() == "yes"
|
config.verbose = verbose:lower() == "yes"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user