-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
83 lines (63 loc) · 1.41 KB
/
Copy pathinit.lua
File metadata and controls
83 lines (63 loc) · 1.41 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--[[
BlueAPI initialization
Loads b_api and b_files
Trims lua extensions
Checks for updates
Sets "blu" alias for self
Parameters
noUpdate - Prevents automatic update check
]]
local user = "blueberrys"
local repo = "cc-blue-api"
local exclFiles = {
"README.md",
"pastebin",
}
local root = "blue-api"
local apis = fs.combine(root, "apis")
local alias, run = "blu", fs.combine(root, "init")
local force_reset = true
--
local function load(path, reset)
if reset and _G[path] then
os.unloadAPI(path)
end
return os.loadAPI(path)
end
local function loadNoLua(path, reset)
local lua_path = path .. ".lua"
if fs.exists(lua_path) then
-- Delete old one
if fs.exists(path) then
fs.delete(path)
end
-- Use new one
fs.move(lua_path, path)
end
return load(path, reset)
end
--
local canUpdate = true
local arg = {...}
for _, a in pairs(arg) do
if a == "noUpdate" then
canUpdate = false
end
end
--
print("Initializing BlueAPI at " .. root)
-- Load b_files, trim lua
loadNoLua(fs.combine(apis, "b_files"), force_reset)
b_files.trimLuaExtDir(root, true)
-- Load b_api
load(fs.combine(apis, "b_api"), force_reset)
b_api.setRoot(apis)
if canUpdate then
-- Load b_update, check for updates
b_api.load("b_update", force_reset)
b_update.gitUpdate(user, repo, "master", root, exclFiles)
end
-- Load b_startup, set alias
b_api.load("b_startup", force_reset)
b_startup.addAlias(alias, run)
shell.setAlias(alias, run)