forked from overextended/ox_lib
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
53 lines (39 loc) · 1.34 KB
/
init.lua
File metadata and controls
53 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local debug_getinfo = debug.getinfo
function noop() end
lib = setmetatable({
name = 'er_lib',
context = IsDuplicityVersion() and 'server' or 'client',
}, {
__newindex = function(self, key, fn)
rawset(self, key, fn)
if debug_getinfo(2, 'S').short_src:find '@er_lib/resource' then exports(key, fn) end
end,
__index = function(self, key)
local dir = ('imports/%s'):format(key)
local chunk = LoadResourceFile(self.name, ('%s/%s.lua'):format(dir, self.context))
local shared = LoadResourceFile(self.name, ('%s/shared.lua'):format(dir))
if shared then chunk = (chunk and ('%s\n%s'):format(shared, chunk)) or shared end
if chunk then
local fn, err = load(chunk, ('@@er_lib/%s/%s.lua'):format(key, self.context))
if not fn or err then return error(('\n^1Error importing module (%s): %s^0'):format(dir, err), 3) end
rawset(self, key, fn() or noop)
return self[key]
end
end,
})
cache = {
resource = lib.name,
game = GetGameName(),
}
if not LoadResourceFile(lib.name, 'web/build/index.html') then
local err =
'^1Unable to load UI. Build er_lib or download the latest release.\n ^3https://github.com/errorism-scripts/er_lib/releases/latest/download/er_lib.zip^0'
function lib.hasLoaded()
return err
end
error(err)
end
function lib.hasLoaded()
return true
end
require = lib.require