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:
Linden
2023-08-02 16:16:37 +10:00
parent b68da917be
commit b014e43e14

View File

@@ -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