mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 07:13:45 +01:00
Clean up persistence.lua
This commit is contained in:
parent
2c5e2e1e5c
commit
69510b1965
@ -3,10 +3,10 @@ local require = ... or require
|
|||||||
local function load(module_name)
|
local function load(module_name)
|
||||||
return assert(loadfile(modlib.mod.get_resource(modlib.modname, "persistence", module_name .. ".lua")))
|
return assert(loadfile(modlib.mod.get_resource(modlib.modname, "persistence", module_name .. ".lua")))
|
||||||
end
|
end
|
||||||
local _ENV = setmetatable({}, {__index = function(_ENV, module_name)
|
return setmetatable({}, {__index = function(self, module_name)
|
||||||
if module_name == "lua_log_file" then
|
if module_name == "lua_log_file" then
|
||||||
local module = load(module_name)()
|
local module = load(module_name)()
|
||||||
_ENV[module_name] = module
|
self[module_name] = module
|
||||||
return module
|
return module
|
||||||
end
|
end
|
||||||
if module_name == "sqlite3" then
|
if module_name == "sqlite3" then
|
||||||
@ -17,8 +17,7 @@ local _ENV = setmetatable({}, {__index = function(_ENV, module_name)
|
|||||||
end
|
end
|
||||||
return func(require"lsqlite3")
|
return func(require"lsqlite3")
|
||||||
end
|
end
|
||||||
_ENV[module_name] = module
|
self[module_name] = module
|
||||||
return module
|
return module
|
||||||
end
|
end
|
||||||
end})
|
end})
|
||||||
return _ENV
|
|
Loading…
Reference in New Issue
Block a user