Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function extractRepository(cpfDir, destDir)
- print("Constructing project...")
- local file = io.open(cpfDir, "r")
- local cFile = nil
- local lc = 0
- local total = 0
- local ox,oy = term.getCursorPos()
- for line in file:lines() do
- if lc > 0 then
- cFile:write(line.."\n")
- lc = lc-1
- term.clearLine()
- term.setCursorPos(ox,oy)
- if lc == 0 then
- cFile:close()
- print("File write complete.")
- else
- term.write(((total-lc)/total * 100).."%")
- end
- elseif string.find(line, "MKDIR") == 1 then
- local newDirPath = destDir.."/"..string.sub(line, 7)
- if fs.exists(newDirPath) then fs.delete(newDirPath) end
- fs.makeDir(newDirPath)
- print("Created dir "..newDirPath)
- elseif string.find(line, "MKFIL") == 1 then
- local newFilPath = destDir.."/"..string.sub(line, 7)
- if fs.exists(newFilPath) then fs.delete(newFilPath) end
- cFile = io.open(newFilPath, "w")
- print("Created file "..newFilPath)
- ox,oy = term.getCursorPos()
- elseif string.find(line, "WRITE") == 1 then
- lc = tonumber(string.sub(line, 7))
- total = lc
- end
- sleep(0)
- end
- print("Project constructed.")
- end
- local lpath = shell.resolve(".").."/snakemaze"
- local repoCode = "xRX6zwr7"
- if fs.exists(lpath) then
- print(lpath.." already exists. Rename or use another directory to install.")
- return
- end
- print("Snake Maze Installer")
- print("Includes exe and 16 levels")
- print("\nInstalling to the following directory:")
- term.setTextColour(colours.yellow)
- print(" "..lpath.."\n")
- term.setTextColour(colours.white)
- term.write("Ready to install? Y/N: ")
- while true do
- local _,p1 = os.pullEvent("key")
- if p1 == keys.y then
- term.setTextColour(colours.lime)
- print("Y\n")
- break
- elseif p1 == keys.n then
- term.setTextColour(colours.red)
- print("N\n")
- os.pullEvent()
- return
- end
- end
- term.setTextColour(colours.white)
- print("Downloading "..repoCode.."... ")
- if not shell.run("pastebin", "get", repoCode, "glrepo") then
- term.setTextColour(colours.red)
- print("failed!")
- return
- end
- extractRepository(shell.resolve(".").."/glrepo", shell.resolve("."))
- print("Deleting archive...")
- fs.delete(shell.resolve(".").."/glrepo")
- print("Installation complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement