-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
37 lines (32 loc) · 1.15 KB
/
main.lua
File metadata and controls
37 lines (32 loc) · 1.15 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
WAREHOUSE = SMODS.current_mod
assert(SMODS.current_mod.lovely, "Lovely patches were not loaded! Make sure your mod is in the right place.")
WAREHOUSE.mod_path = SMODS.current_mod.path .. ""
local function load_file(path, ...)
local f, err = SMODS.load_file(path)
if err then error(err) end
return f(...)
end
function WAREHOUSE.load_module(mod)
local f, err, path_prefix
if WAREHOUSE.current_module == nil then
path_prefix = ""
else
path_prefix = WAREHOUSE.current_module .. "/"
end
if NFS.getInfo(WAREHOUSE.mod_path .. "/" .. path_prefix .. mod .. "/mod.lua") ~= nil then
print("[WAREHOUSE] Loading module " .. path_prefix .. mod .. "/mod.lua...")
f, err = SMODS.load_file(path_prefix .. mod .. "/mod.lua")
else
print("[WAREHOUSE] Loading module " .. path_prefix .. mod .. ".lua...")
f, err = SMODS.load_file(path_prefix .. mod .. ".lua")
end
if err then error(err) end
local old_mod = WAREHOUSE.current_module
WAREHOUSE.current_module = path_prefix .. mod
local res = f()
WAREHOUSE.current_module = old_mod
print("[WAREHOUSE] Loaded module " .. path_prefix .. mod)
return res
end
WAREHOUSE.current_module = nil
WAREHOUSE.load_module "src"