SHARE
TWEET

os

a guest Sep 22nd, 2016 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CarbonOS = true
  2. os.loadAPI("/System/APIs/sha256")
  3. local function center(text)
  4.   local x,y = term.getSize()
  5.   local x2,y2 = term.getCursorPos()
  6.   term.setCursorPos(math.floor((x / 2) - (text:len() / 2)), y2)
  7.   end
  8. local mon = peripheral.find("monitor")
  9. if mon then
  10.    secondDisplay = true
  11.    mon.setBackgroundColor(colors.brown)
  12.    mon.clear()
  13. else
  14. secondDisplay = nil
  15. end
  16. function init()
  17. tmp = fs.open("/System/.firstuse", "r")
  18. if tmp.readLine() == "true" then
  19.    firstUse = true
  20. end
  21. tmp.close()
  22. boot = paintutils.loadImage("/System/Images/boot") --Turns the boot image into a variable that can be loaded at any time
  23. desktop = paintutils.loadImage("/System/Images/desktop") --Turns the desktop background image into a variable that can be loaded at any time
  24. term.clear()
  25. paintutils.drawImage(boot, 1,1)
  26. os.sleep(2)
  27. term.setBackgroundColor(colors.brown)
  28. term.clear()
  29. term.setCursorPos(1,1)
  30. if firstUse then
  31.    textutils.slowPrint("Welcome to CarbonOS!")
  32.    print()
  33.    textutils.slowPrint("CarbonOS is a simple, fast, and easy to use OS.")
  34.    print()
  35.    textutils.slowPrint("Before you can use this OS, You will have to go through the setup.")
  36.    print()
  37.    textutils.slowPrint("The setup is very quick and should not take more then 5 minutes.")
  38.    os.sleep(3)
  39.    term.clear()
  40.    term.setCursorPos(1,1)
  41.    center("Account")
  42.    term.setCursorPos(2,10)
  43.    print("With an account, you can install your own Programs, set Parental Controls for your child(s), and do much more!")
  44.    print("You can also have your own files for each account.")
  45.    print()
  46.    term.write("Username: ")
  47.    user = read()
  48.    term.write("Password: ")
  49.    pass = read()
  50.    print()
  51.    print("Creating Account...")
  52.    local salt = "amazing"
  53.    local hash = sha256.pbkdf2(pass, salt, 100)
  54.    fs.makeDir(fs.combine("/System/Users/", user))
  55.    shell.run("cd /System/Users/", user)
  56.    fs.makeDir("Programs")
  57.    fs.makeDir("Documents")
  58.    local welcome = {
  59.                    "Welcome to CarbonOS!",
  60.                    "You can do alot of things in this OS",
  61.                    "Notice the GUI? You can do alot of things with the Amazing GUI",
  62.                    "What do all OS's miss out? The fact that cannot extend programs on to muliple monitors",
  63.                    "CarbonOS is the First OS that can!",
  64.                    "Thank You for using CarbonOS!",
  65.                    "Credits:",
  66.                    "Anavrins - SHA256 API",
  67.                    "oeed - Ink",
  68.                    "GravityScore - LuaIDE",
  69.                    "Thank You!"
  70.                    }
  71.    shell.run("cd", fs.combine("/System/Users/", user))
  72.    shell.run("cd Documents")
  73.    file = fs.open(fs.combine("/System/Users/", user, "w"))
  74.    for _,line in ipairs(welcome) do
  75.    file.write(line)
  76.    end
  77.    file.close()
  78.    print("Done!")
  79.    term.clear()
  80.    term.setCursorPos(1,1)
  81.    textutils.slowPrint("You can now use CarbonOS!")
  82.    textutils.slowPrint("Enjoy!")
  83.    os.sleep(1)
  84.    os.reboot()
  85.          
  86.                    
  87. end
  88. paintutils.drawImage(desktop, 1,1)
  89. local w, h = term.getSize()
  90. term.setCursorPos(1, h)
  91. term.setBackgroundColor(colors.green)
  92. term.write("Start                                              ") --Displays the start button
  93. local event, x, y, button = os.pullEvent("mouse_click") --Recognizes mouse clicks
  94. end
  95. local ok, error = pcall(init)
  96. if error then
  97.    term.clear()
  98.    term.setBackgroundColor(colors.blue)
  99.    term.clear()
  100.    term.setCursorPos(1,1)
  101.    print("Sorry! CarbonOS has Encountered a Serious Error!")
  102.    print("Error: ", error)
  103.    print()
  104.    print("Press any key to reboot.")
  105.    os.pullEvent("key")
  106.    --os.reboot()
  107.    return
  108. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top