-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.lua
59 lines (49 loc) · 1.39 KB
/
install.lua
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
-- filepath: d:\luaasm\install.lua
-- LuaASM Installer for ComputerCraft
-- Downloads files from a Forgejo Git server and sets up the LuaASM environment.
-- Configuration
local GIT_SERVER = "https://git.carsoncoder.com"
local REPO = "charlie-san/LuaASM"
local BRANCH = "main"
local FILES = {
"interp.lua",
"debugger.lua",
"tui.lua",
"main.masm",
"root/stdio/print.masm",
"README.md",
"v2instructions.md"
}
-- Helper function to download a file
local function downloadFile(url, path)
local response, err = http.get(url)
if not response then
error("Failed to download " .. url .. ": " .. err)
end
local content = response.readAll()
response.close()
-- Ensure the directory exists
local dir = path:match("^(.*)/")
if dir and not fs.exists(dir) then
fs.makeDir(dir)
end
-- Write the file
local file = fs.open(path, "w")
file.write(content)
file.close()
print("Downloaded: " .. path)
end
-- Main installation function
local function install()
print("Starting LuaASM installation...")
for _, file in ipairs(FILES) do
local url = string.format("%s/%s/raw/branch/%s/%s", GIT_SERVER, REPO, BRANCH, file)
downloadFile(url, file)
end
print("LuaASM installation complete!")
end
-- Run the installer
local ok, err = pcall(install)
if not ok then
printError("Installation failed: " .. err)
end