refactor(resource): load extra modules

This commit is contained in:
Linden
2024-04-01 19:15:04 +11:00
parent 989462da7d
commit 09ca963f26
3 changed files with 25 additions and 19 deletions

View File

@@ -1,21 +1,24 @@
--[[ FX Information ]]-- --[[ FX Information ]]
fx_version 'cerulean' --
fx_version 'cerulean'
use_experimental_fxv2_oal 'yes' use_experimental_fxv2_oal 'yes'
lua54 'yes' lua54 'yes'
games { 'rdr3', 'gta5' } games { 'rdr3', 'gta5' }
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
--[[ Resource Information ]]-- --[[ Resource Information ]]
name 'ox_lib' --
author 'Overextended' name 'ox_lib'
version '3.18.0' author 'Overextended'
license 'LGPL-3.0-or-later' version '3.18.0'
repository 'https://github.com/overextended/ox_lib' license 'LGPL-3.0-or-later'
description 'A library of shared functions to utilise in other resources.' repository 'https://github.com/overextended/ox_lib'
description 'A library of shared functions to utilise in other resources.'
--[[ Manifest ]]-- --[[ Manifest ]]
--
dependencies { dependencies {
'/server:7290', '/server:7290',
'/onesync', '/onesync',
} }
@@ -23,17 +26,19 @@ ui_page 'web/build/index.html'
files { files {
'init.lua', 'init.lua',
'resource/settings.lua',
'imports/**/client.lua', 'imports/**/client.lua',
'imports/**/shared.lua', 'imports/**/shared.lua',
'web/build/index.html', 'web/build/index.html',
'web/build/**/*', 'web/build/**/*',
'locales/*.json', 'locales/*.json',
} }
shared_script 'resource/init.lua' shared_script 'resource/init.lua'
shared_scripts { shared_scripts {
'resource/**/shared.lua', 'resource/**/shared.lua',
'imports/require/shared.lua',
-- 'resource/**/shared/*.lua' -- 'resource/**/shared/*.lua'
} }
@@ -43,8 +48,8 @@ client_scripts {
} }
server_scripts { server_scripts {
'imports/callback/server.lua', 'imports/callback/server.lua',
'imports/getFilesInDirectory/server.lua',
'resource/**/server.lua', 'resource/**/server.lua',
'resource/**/server/*.lua', 'resource/**/server/*.lua',
} }

View File

@@ -108,7 +108,7 @@ end
---Loads the given module inside the current resource, returning any values returned by the file or `true` when `nil`. ---Loads the given module inside the current resource, returning any values returned by the file or `true` when `nil`.
---@param modname string ---@param modname string
---@return unknown? ---@return unknown
function lib.require(modname) function lib.require(modname)
if type(modname) ~= 'string' then return end if type(modname) ~= 'string' then return end

View File

@@ -43,7 +43,8 @@ cache = {
} }
if not LoadResourceFile(lib.name, 'web/build/index.html') then if not LoadResourceFile(lib.name, 'web/build/index.html') then
local err = '^1Unable to load UI. Build ox_lib or download the latest release.\n ^3https://github.com/overextended/ox_lib/releases/latest/download/ox_lib.zip^0' local err =
'^1Unable to load UI. Build ox_lib or download the latest release.\n ^3https://github.com/overextended/ox_lib/releases/latest/download/ox_lib.zip^0'
function lib.hasLoaded() return err end function lib.hasLoaded() return err end
error(err) error(err)
@@ -51,4 +52,4 @@ end
function lib.hasLoaded() return true end function lib.hasLoaded() return true end
lib.locale() require = lib.require