Advertisement
Theshadow989

[xOS] Startup

Jan 6th, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. --[[
  2. Startup File
  3. Written by TheShadow989
  4. ]]--
  5.  
  6. os.pullEvent = os.pullEventRaw
  7. os.loadAPI("xos/api/sha256")
  8.  
  9. local verNumber = "Alpha 1.24"
  10. local tries = 1
  11.  
  12. rRead = fs.open("xos/.usertable", "r")
  13. users = textutils.unserialize(rRead.readAll())
  14. rRead.close()
  15.  
  16. local x = term.getSize()
  17.  
  18. local function cPrint(string)
  19.         x, _ = term.getSize()
  20.         _, y = term.getCursorPos()
  21.         term.setCursorPos((x-#string)/2,y)
  22.         textutils.slowPrint(string)
  23. end
  24.  
  25. --if users[5] == nil and users[8] == nil and users[11] == nill then
  26.     --shell.run("xos/.firsttime")
  27. --end
  28.  
  29. term.clear()
  30. term.setCursorPos(1,19)
  31.  
  32. term.write("xOS "..verNumber.." by TheShadow989")
  33.  
  34. term.setCursorPos(1,2)
  35.  
  36. cPrint("xOS "..verNumber)
  37. sleep(1)
  38.  
  39. while true do
  40.     if tries == 4 then
  41.         term.setCursorPos(1,8)
  42.         term.clearLine()
  43.         term.setCursorPos(22,10)
  44.         term.clearLine()
  45.         write("LOCKED")
  46.         sleep(120)
  47.         tries = 1
  48.         term.clearLine()
  49.     end
  50.  
  51.     term.setCursorPos(17,8)
  52.     term.clearLine()
  53.     write("Username: ")
  54.     term.setCursorPos(17,10)
  55.     term.clearLine()
  56.     write("Password: ")
  57.     term.setCursorPos(27,8)
  58.     user = read()
  59.     term.setCursorPos(27,10)
  60.     pass = read('*')
  61.  
  62.     pass = sha256.sha256(pass)
  63.    
  64.     for i=2, #users, 3 do
  65.         if user == users[i] and pass == users[i + 2] then
  66.             users[1] = ""..i..""
  67.             access = true
  68.         end
  69.     end
  70.  
  71.     tries = tries + 1
  72.  
  73.     if access == true then
  74.         break
  75.     end
  76.  
  77.     if tries ~= 4 then
  78.         term.setCursorPos(5,14)
  79.         term.setTextColor( colors.red )
  80.         write("Incorrect username and password combination.")
  81.         term.setTextColor( colors.white )
  82.         sleep(3)
  83.         term.clearLine()
  84.     end
  85. end
  86.  
  87.  
  88. term.setCursorPos(19,14)
  89. write("Logging in...")
  90. term.setCursorPos(16,15)
  91. write("[                ]")
  92. term.setCursorPos(17,15)
  93. write("###")
  94. sleep(0.5)
  95. term.setCursorPos(20,15)
  96. write("###")
  97. sleep(1)
  98. term.setCursorPos(23,15)
  99. write("#####")
  100. sleep(0.2)
  101. term.setCursorPos(28,15)
  102. write("##")
  103. sleep(1)
  104. term.setCursorPos(30,15)
  105. write("###")
  106. sleep(0.5)
  107.  
  108. rWrite = fs.open("xos/.usertable", "w")
  109. rWrite.write(textutils.serialize(users))
  110. rWrite.close()
  111. shell.run(".menu")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement