mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(init): importing modules with resource metadata
Allow loading modules through fxmanifest (i.e. ox_lib 'locale' or ox_libs { 'locale' }).
Useful in some cases where the module needs to be loaded (lib.locale()) first.
This commit is contained in:
12
init.lua
12
init.lua
@@ -149,7 +149,7 @@ end
|
||||
lua language server doesn't support generics when using @overload
|
||||
see https://github.com/LuaLS/lua-language-server/issues/723
|
||||
this function stub allows the following to work
|
||||
|
||||
|
||||
local key = cache('key', function() return 'abc' end) -- fff: 'abc'
|
||||
local game = cache.game -- game: string
|
||||
]]
|
||||
@@ -218,3 +218,13 @@ else
|
||||
TriggerClientEvent(notifyEvent, playerId, data)
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, GetNumResourceMetadata(cache.resource, 'ox_lib') do
|
||||
local name = GetResourceMetadata(cache.resource, 'ox_lib', i - 1)
|
||||
|
||||
if not rawget(lib, name) then
|
||||
local module = loadModule(lib, name)
|
||||
|
||||
if type(module) == 'function' then pcall(module) end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user