Advertisement
TaZeOS

OS/login.lua

Nov 3rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. log(" ")
  2. log("-------------------------")
  3. log("Running login.lua")
  4. log("-------------------------")
  5. log(" ")
  6.  
  7. function s(...) return sleep(...) end
  8. function w(...) return write(...) end
  9. function p(...) return print(...) end
  10. function tw(...) return term.write(...) end
  11. function scp(...) return term.setCursorPos(...) end
  12. function sbc(...) return term.setBackgroundColor(...) end
  13. function stc(...) return term.setTextColor(...) end
  14. function tc(...) return term.clear(...) end
  15. function tcl(...) return term.clearLine() end
  16. function scb(...) return term.setCursorBlink(...) end
  17. function ts(...) return term.scroll(...) end
  18. function r(...) return shell.run(...) end
  19. function para(...) return parallel.waitForAny(...) end
  20. function sw(...) return textutils.slowWrite(...) end
  21. function sp(...) return textutils.slowPrint(...) end
  22. log("==> Creating incorrect password window")
  23. wrong = window.create(term.current(),28,10,22,7)
  24. wrong.setVisible(false)
  25. log("==> Clearing screen")
  26. sbc(colors.cyan)
  27. term.clear()
  28. log("==> Loading User data")
  29.  
  30.  
  31.  
  32.  
  33. log("==> Loading and drawing computer image")
  34. computer = paintutils.loadImage("OS/computer.png")
  35. paintutils.drawImage(computer, 3, 3 )
  36.  
  37. log("==> Adding content to incorrect password window")
  38. wrong.setBackgroundColor(colors.white)
  39. wrong.clear()
  40. wrong.setCursorPos(1,1)
  41. wrong.setBackgroundColor(colors.blue)
  42. wrong.write(" Wrong Information ")
  43. wrong.setCursorPos(1,3)
  44. wrong.setBackgroundColor(colors.white)
  45. wrong.setTextColor(colors.black)
  46. wrong.write(" Wrong password or")
  47. wrong.setCursorPos(1,4)
  48. wrong.write(" Username please try")
  49. wrong.setCursorPos(1,5)
  50. wrong.write(" again.")
  51.  
  52.  
  53. scp(28,4)
  54. sbc(colors.cyan)
  55. print("Login")
  56. while true do
  57. log("==> Creating username box")
  58. username = window.create(term.current(),28,6,23,1)
  59. username.setBackgroundColor(colors.white)
  60. username.clear()
  61. log("==> Creating password box")
  62. password = window.create(term.current(),28,8,23,1)
  63. password.setBackgroundColor(colors.white)
  64. password.clear()
  65. sbc(colors.white)
  66. stc(colors.black)
  67. scp(28,6)
  68. log("==> Allowing input for username")
  69. username = read()
  70. scp(28,8)
  71. stc(colors.black)
  72. sbc(colors.white)
  73. log("==> Allowing input for password")
  74. password = read("*")
  75. log("==> Recvied username and password")
  76. log("Checking if it matches any user data")
  77. checkUser()
  78.  
  79. if username == UserInfo[1][1] and password == UserInfo[1][2] or username == UserInfo[2][1] and password == UserInfo[2][2] or username == UserInfo[3][1] and password == UserInfo[3][2] or username == UserInfo[4][1] and password == UserInfo[4][2] then
  80. log("==> Data found... Logging into user \""..username1.."\"")
  81. log("==> Checking permissions")
  82. CurrentUser = username
  83. if username == UserInfo[1][1] then
  84. admin = UserInfo[1][3]
  85. elseif username == UserInfo[2][1] then
  86. admin = UserInfo[2][3]
  87. elseif username == UserInfo[3][1] then
  88. admin = UserInfo[3][3]
  89. elseif username == UserInfo[4][1] then
  90. admin = UserInfo[4][3]
  91. end
  92. sbc(colors.cyan)
  93. term.clear()
  94. paintutils.drawImage(computer, 3, 3 )
  95. scp(25,7)
  96. sbc(colors.cyan)
  97. stc(colors.white)
  98. term.write("Loading Desktop")
  99. local i = 1
  100. log("==> Loading and displaying loading images")
  101. loadingicon = paintutils.loadImage("OS/loading.png")
  102. repeat
  103.  
  104. paintutils.drawImage(loadingicon, 28, 9 )
  105. sleep(1)
  106. paintutils.drawImage(loadingicon, 32, 9 )
  107. sleep(1)
  108. paintutils.drawImage(loadingicon, 36, 9 )
  109. sleep(1)
  110. scp(1,9)
  111. sbc(colors.cyan)
  112. term.write(" ")
  113.  
  114.  
  115.  
  116. i = i + 1
  117. paintutils.drawImage(computer, 3, 3 )
  118. until i == 2
  119. shell.run('OS/desktop.lua')
  120. log("ERROR ==> login.lua has been resumed, a app may of crashed. (NEAR LN108, OS/login.lua)")
  121.  
  122.  
  123. sbc(colors.cyan)
  124. term.clear()
  125. paintutils.drawImage(computer, 3, 3 )
  126.  
  127. errormessage = window.create(term.current(),15,7,25,6)
  128. errormessage.setBackgroundColor(colors.white)
  129. errormessage.clear()
  130. errormessage.setCursorPos(1,1)
  131. errormessage.setBackgroundColor(colors.red)
  132. errormessage.write(" Error ")
  133. errormessage.setTextColor(colors.black)
  134. errormessage.setCursorPos(2,2)
  135. errormessage.setBackgroundColor(colors.white)
  136. errormessage.write("A error has occurred!")
  137. errormessage.setCursorPos(2,3)
  138. errormessage.write("Please check the log to")
  139. errormessage.setCursorPos(2,4)
  140. errormessage.write("find out more info.")
  141. errormessage.setCursorPos(10,5)
  142. errormessage.setBackgroundColor(colors.lightGray)
  143. errormessage.setTextColor(colors.white)
  144. errormessage.write(" Ok ")
  145.  
  146. while true do
  147.  
  148. local event, button, x, y = os.pullEvent("mouse_click")
  149.  
  150. if x >= 24 and x <= 27 and y == 11 then
  151.  
  152. shell.run('OS/login.lua')
  153.  
  154. end
  155. end
  156.  
  157. else
  158. log("ERROR ==> Input we recived did not match any user data... Displaying error message to user")
  159. wrong.setVisible(true)
  160. end
  161. end
  162. sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement