2021-08-24 19:45:59 +00:00
|
|
|
local function isModuleAvailable(name)
|
2021-10-02 05:15:50 +00:00
|
|
|
if package.loaded[name] then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
for _, searcher in ipairs(package.searchers or package.loaders) do
|
|
|
|
local loader = searcher(name)
|
|
|
|
if type(loader) == "function" then
|
|
|
|
package.preload[name] = loader
|
|
|
|
return true
|
|
|
|
end
|
2021-08-24 19:45:59 +00:00
|
|
|
end
|
2021-10-02 05:15:50 +00:00
|
|
|
return false
|
|
|
|
end
|
2021-08-24 19:45:59 +00:00
|
|
|
end
|
|
|
|
|
2021-10-02 05:15:50 +00:00
|
|
|
local loadIfExists = function(module)
|
|
|
|
if isModuleAvailable(module) then
|
|
|
|
require(module)
|
|
|
|
end
|
2021-08-24 19:45:59 +00:00
|
|
|
end
|
|
|
|
|
2021-10-02 05:15:50 +00:00
|
|
|
loadIfExists "custom"
|