SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local repoCode = "Y4Dih69H" |
| 1 | + | local repoCode = "G73Vyqbk" |
| 2 | - | local lpath = shell.resolve("-i")
|
| 2 | + | local lpath = shell.resolve("columndrop")
|
| 3 | print("column Installer")
| |
| 4 | print("A tetris-inspired falling block puzzle game")
| |
| 5 | local function printC(str, col) | |
| 6 | if col and term.isColour() then | |
| 7 | term.setTextColour(col) | |
| 8 | end | |
| 9 | print(str) | |
| 10 | term.setTextColour(colours.white) | |
| 11 | end | |
| 12 | ||
| 13 | local function extractRepository(cpfDir, destDir) | |
| 14 | print("\nConstructing project...")
| |
| 15 | local f1 = fs.open(shell.resolve("temprepo"), "r")
| |
| 16 | local f2 = nil | |
| 17 | ||
| 18 | local fcount = 0 | |
| 19 | ||
| 20 | local line = f1.readLine() | |
| 21 | while line do | |
| 22 | if string.sub(line,1,5) == "MKDIR" then | |
| 23 | fs.makeDir(shell.resolve(string.sub(line,7))) | |
| 24 | elseif string.sub(line,1,5) == "MKFIL" then | |
| 25 | fcount = fcount + 1 | |
| 26 | f2 = fs.open(shell.resolve(string.sub(line, 7)), "w") | |
| 27 | elseif string.sub(line,1,5) == "WRITE" then | |
| 28 | count = tonumber(string.sub(line,7)) | |
| 29 | while count > 0 do | |
| 30 | f2.writeLine(f1.readLine()) | |
| 31 | count = count - 1 | |
| 32 | end | |
| 33 | f2.close() | |
| 34 | end | |
| 35 | line = f1.readLine() | |
| 36 | end | |
| 37 | ||
| 38 | f1.close() | |
| 39 | printC("Project constructed. "..fcount.." files created")
| |
| 40 | end | |
| 41 | ||
| 42 | if not http then | |
| 43 | printC("\nHTTP not enabled on this computer. Installation aborted.", colours.red)
| |
| 44 | return 2 | |
| 45 | end | |
| 46 | ||
| 47 | if fs.exists(lpath) then | |
| 48 | printC("\n/"..lpath.." already exists. Rename or use another directory to install.", colours.red)
| |
| 49 | return 1 | |
| 50 | end | |
| 51 | ||
| 52 | print("\nInstalling to the following directory:")
| |
| 53 | if term.isColour() then term.setTextColour(colours.yellow) end | |
| 54 | print(" /"..lpath.."\n")
| |
| 55 | term.setTextColour(colours.white) | |
| 56 | term.write("Ready to install? Y/N: ")
| |
| 57 | ||
| 58 | while true do | |
| 59 | local _,p1 = os.pullEvent("key")
| |
| 60 | if p1 == keys.y then | |
| 61 | printC("Y\n", colours.lime)
| |
| 62 | break | |
| 63 | elseif p1 == keys.n then | |
| 64 | printC("N\n", colours.red)
| |
| 65 | printC("Installation cancelled!")
| |
| 66 | return 1 | |
| 67 | end | |
| 68 | end | |
| 69 | ||
| 70 | local trval = "" | |
| 71 | ||
| 72 | if (fs.exists(shell.resolve("temprepo"))) then
| |
| 73 | trval = 0 | |
| 74 | while (fs.exists(shell.resolve("temprepo"..trval))) do
| |
| 75 | trval = trval + 1 | |
| 76 | end | |
| 77 | end | |
| 78 | ||
| 79 | print("Downloading repo "..repoCode.."...")
| |
| 80 | if not shell.run("pastebin", "get", repoCode, "temprepo"..trval) then
| |
| 81 | print("Installation failed; could not access pastebin", colours.red)
| |
| 82 | return 2 | |
| 83 | end | |
| 84 | ||
| 85 | extractRepository(shell.resolve("temprepo"..trval), shell.resolve("."))
| |
| 86 | fs.delete(shell.resolve("temprepo"..trval))
| |
| 87 | ||
| 88 | if term.isColour() then term.setTextColour(colours.lime) end | |
| 89 | print("Installation complete!")
| |
| 90 | return 0 |