Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- /**
- * lzModuleLoader
- *
- * Loads modules that are based on the
- * JavaScript Module pattern
- *
- * @copyright (C) LayZee 2014
- */
- --]]
- local fileExists = function(filename)
- local file = io.open(filename, 'r')
- if file == nil then
- return false
- end
- io.close(file)
- return true
- end
- load = function(moduleName, aliasName)
- local filename = 'lz.' .. moduleName
- assert(
- fileExists(filename),
- 'File \'' .. filename
- .. '\' does not exist'
- )
- _G.lz = _G.lz or {}
- _G.lz[moduleName] = (loadfile(filename))()
- if aliasName then
- _G.lz[aliasName] = _G.lz[moduleName]
- end
- local moduleTitle = 'lz'
- .. moduleName:gsub(
- '^%l',
- string.upper
- )
- print(moduleTitle .. ' v'
- .. _G.lz[moduleName].VERSION
- .. ' loaded'
- )
- end
Advertisement
Add Comment
Please, Sign In to add comment