-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
48 lines (38 loc) · 1.34 KB
/
Copy pathmain.lua
File metadata and controls
48 lines (38 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
local BASALT_PATH = "/basalt.lua"
local BASALT_URL = "https://basalt.madefor.cc/2.5/install.lua"
local function ensureBasalt()
if not fs.exists(BASALT_PATH) then
print("Installing Basalt...")
local previousDirectory = shell.dir()
shell.setDir("/")
local installCallSucceeded, installed = pcall(
shell.run,
"wget",
"run",
BASALT_URL,
"minified"
)
shell.setDir(previousDirectory)
if not installCallSucceeded or not installed
or not fs.exists(BASALT_PATH) then
error("Failed to install Basalt.", 0)
end
end
package.path = "/?.lua;" .. package.path
local loaded, basalt = pcall(require, "basalt")
if not loaded then
error("Failed to load Basalt: " .. tostring(basalt), 0)
end
return basalt
end
local function loadApplication(basalt)
local runningProgram = shell.getRunningProgram()
local projectRoot = fs.getDir(shell.resolve(runningProgram))
local applicationPath = fs.combine(projectRoot, "src/app.lua")
local application, loadError = loadfile(applicationPath, nil, _ENV)
if not application then
error("Failed to load Turtle Toolbox: " .. tostring(loadError), 0)
end
return application(basalt, projectRoot)
end
loadApplication(ensureBasalt())