Advertisement
FishtoastleProgramer

FTosStartup

Jul 11th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. local w,h = term.getSize()
  2. --local FILE = fs.open(".version","r")
  3. --local Ver = FILE.readLine()
  4. --FILE.close()
  5. --functions
  6. local function printCentered(str, ypos)
  7.   term.setCursorPos(w/2 - #str/2, ypos)
  8.   term.write(str)
  9. end
  10. local function logIn()
  11.     term.clear()
  12.     term.setCursorPos(1,1)
  13.     local linfo = fs.exists("logInfo")
  14.     if linfo == true then
  15.         printCentered("Please login to continue",1)
  16.         printCentered(string.rep("-",w),2)
  17.         printCentered("username:",5)
  18.         local user = read()
  19.         printCentered("password:",7)
  20.         local pass = read()
  21.         local User = fs.open("logInfo/.UserName","r")
  22.         local Pass = fs.open("logInfo/.PassWord","r")
  23.         local Username = User.readLine()
  24.         local Password = Pass.readLine()       
  25.    
  26.         if user == Username and pass == Password then
  27.             printCentered("login sucsseful",9)
  28.             sleep(1)
  29.             shell.run(".menu")
  30.         else
  31.             printCentered("login incorrect",9)
  32.             sleep(1)
  33.             os.shutdown()
  34.         end
  35.     else
  36.         print("so your new?")
  37.         print("what would you like to be called?")
  38.         newUser = read()
  39.         print("what would you like for a password?")
  40.         newPass = read()
  41.         fs.makeDir("logInfo")
  42.         newU = fs.open("logInfo/.UserName","a")
  43.         newU.writeLine(newUser)
  44.         newU.close()
  45.         newP = fs.open("logInfo/.PassWord","a")
  46.         newP.writeLine(newPass)
  47.         newP.close()
  48.         shell.run("reboot")
  49.     end
  50. end
  51. local function updateCheck()
  52.     term.clear()
  53.     printCentered("checking for updates",h/2)
  54.     term.setCursorPos(1,h+1)
  55.     local True = shell.run("pastebin get","Qvzk5rrV","versionCheck")
  56.     if True == true then
  57.         local File1 = fs.open("versionCheck","r")
  58.         local File2 = fs.open(".version","r")
  59.         local Lver = File2.readLine()
  60.         local Gver = File1.readLine()
  61.         os.sleep(1)
  62.     if Gver == Lver then
  63.         File1.close()
  64.         File2.close()
  65.         printCentered("this system is up to date",h/2)
  66.         os.sleep(2)
  67.         shell.run("delete","versionCheck")
  68.     else
  69.         File1.close()
  70.         File2.close()  
  71.         printCentered("there is a new update",h/2)
  72.         os.sleep(0.2)
  73.         printCentered("installing now",h/2)
  74.         shell.run("delete","versionCheck")
  75.         shell.run("pastebin run","kVGQjw3A")
  76.     end
  77.     end
  78. end
  79. --initilizer
  80. printCentered("initailizing FToS",1)
  81. term.setCursorPos(1,2)
  82. print(string.rep("-",w))
  83. os.sleep(2)
  84. term.setCursorPos(2,h-2)
  85. for i = 0,w - 4 do
  86. term.setBackgroundColor(colors.blue)
  87. write(" ")
  88. os.sleep(0.2)
  89. term.setBackgroundColor(colors.black)
  90. write(" ")
  91. end
  92. term.setBackgroundColor(colors.black)
  93. os.sleep(1)
  94. updateCheck()
  95. logIn()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement