Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get width and height
- local w, h = term.getSize()
- mY = 8
- -- Clear screen
- term.clear()
- -- Function for printing in center of screen
- function cPrint(msg, y)
- term.setCursorPos(math.floor((w-#msg)/2) + (#msg % 2 == 0 and 1 or 0), y or h/2)
- print(msg)
- end
- function cWrite(msg, y)
- term.setCursorPos(math.floor((w-#msg)/2) + (#msg % 2 == 0 and 1 or 0), y or h/2)
- term.write(msg)
- end
- -- Check if computer is advanced
- if not term.isColor() then
- error("Sorry, we only support advanced computers")
- end
- -- Check if HTTP is enabled
- if not http.get("http://example.com/", headers) then
- error("HTTP API not enabled. Please enable this to install")
- end
- term.setBackgroundColor(2048)
- term.setTextColor(1)
- term.clear()
- cPrint("Welcome!", 2)
- cPrint("We see this is the first time you run SkyOS.", 4)
- cPrint("Choose what you would like to do below: ", 6)
- cPrint("[Install]", mY)
- cPrint("Exit", 10)
- function installFile(url, filename)
- local file = fs.open(filename, 'w')
- file.write(http.get(url).readAll())
- file.close()
- end
- function install()
- term.clear()
- cPrint("Installing. Step [1/2]", 2)
- cWrite("What's your name? ", 4)
- local name = read()
- cPrint("Welcome "..name.."!",6)
- cWrite("What would you like your password to be? ", 8)
- local pass = read('*')
- if not fs.exists("users") then
- fs.makeDir("users")
- end
- if not fs.exists("users/"..name) then
- local file = fs.open("users/"..name, "a")
- file.writeLine(pass)
- file.close()
- end
- cWrite("What would you like to name your computer? ", 10)
- local cName = read()
- os.setComputerLabel(cName)
- cPrint("Your computers name is now "..cName.."!", 12)
- sleep(1)
- term.clear()
- cPrint("Installing. Step [2/2]", 2)
- cPrint("Downloading files...", 4)
- cPrint("Getting files!", 6)
- installFile("https://raw.githubusercontent.com/Mackan90096/skyos/master/startup", "startup")
- installFile("https://raw.githubusercontent.com/Mackan90096/skyos/master/api/text", "api/text")
- installFile("https://raw.githubusercontent.com/Mackan90096/skyos/master/programs/pasteget", "programs/pasteget")
- installFile("https://raw.githubusercontent.com/Mackan90096/skyos/master/programs/edit", "programs/edit")
- cPrint("Done! Computer will now reboot", 8)
- sleep(1)
- os.reboot()
- end
- while true do
- e, p1, p2, p3 = os.pullEvent()
- if e == "key" then
- if p1 == 208 then
- if mY == 8 then
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("Install", mY)
- mY = 10
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("[Exit]", mY)
- elseif mY == 10 then
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("Exit", mY)
- mY = 8
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("[Install]", mY)
- end
- elseif p1 == 200 then
- if mY == 10 then
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("Exit", mY)
- mY = 8
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("[Install]", mY)
- elseif mY == 8 then
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("Install", mY)
- mY = 10
- term.setCursorPos(1, mY)
- term.clearLine()
- cPrint("[Exit]", mY)
- end
- elseif p1 == 28 then
- if mY == 10 then
- os.reboot()
- elseif mY == 8 then
- install()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement