forked from aquapha/lua-vBuilder-fivem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
69 lines (55 loc) · 1.69 KB
/
init.lua
File metadata and controls
69 lines (55 loc) · 1.69 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- Only allow Lua 5.4
if not _VERSION:find('5.4') then
error('^1Lua 5.4 must be enabled in the resource manifest!^0', 2)
end
local surePrism = 'sure_prism'
local resourceName = GetCurrentResourceName()
--- Avoid initializing the module if it's within itself
if resourceName == surePrism then
return
end
if GetResourceState(surePrism) ~= 'started' then
error('^1sure_prism must be started before this resource.^0', 0)
end
local LoadResourceFile = LoadResourceFile
--- Must be manually updated
local moduleRoutes = {
'lib/generator.lua',
--- [validator:utils]
'lib/validator/utils/table.lua',
'lib/validator/utils/is-array.lua',
'lib/validator/utils/validate-builder.lua',
--- [validator:root]
'lib/validator/enums.lua',
--- [validator:parsers]
'lib/validator/parsers/alphanumeric-parser.lua',
'lib/validator/parsers/boolean-parser.lua',
'lib/validator/parsers/array-parser.lua',
'lib/validator/parsers/enum-parser.lua',
'lib/validator/parsers/object-parser.lua',
'lib/validator/parsers/union-parser.lua',
'lib/validator/parser.lua',
--- [validator:methods]
'lib/validator/methods/primitive-methods.lua',
'lib/validator/methods/table-methods.lua',
--- [validator:root]
'lib/validator/primitive-builders.lua',
--- [event:root]
'lib/event/use.lua',
}
---@param module string
local function loadModule(module)
local chunk = LoadResourceFile(surePrism, module)
if not chunk then
return
end
local fun, err = load(chunk, ('@@sure_prism/%s'):format(module))
if not fun or err then
return error(('\n^1Error importing module (%s): %s^0'):format(module, err), 3)
end
fun()
end
for i = 1, #moduleRoutes do
local name = moduleRoutes[i]
loadModule(name)
end