Lua Require From Root (RFR)

Date: 2018-09-26
local loadedModules = {}
local function loadModule(name, unload)
	if (unload) then
		loadedModules[name] = nil
	end

	if loadedModules[name] then 
		return loadedModules[name] 
	end

	local fileName = name .. '.lua'
	local moduleContent, err = loadfile(fileName)
	if (err) then
		error(string.format("error loading module: %s\r\n%s", name, err), 2);
	end
	loadedModules[name] = moduleContent() or true	
	return loadedModules[name]
end

return loadModule
13070cookie-checkLua Require From Root (RFR)