Advertisement
Guest User

Client.lua

a guest
Mar 30th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. --Variables--
  2. User = nil
  3. Pass = nil
  4. A = nil
  5. Init = nil
  6.  
  7. local function Reset()
  8. shell.run("clear")
  9. term.setBackgroundColor(colors.blue)
  10. term.clear()
  11. term.setTextColor(colors.white)
  12. textutils.slowPrint("Banking System")
  13. end
  14.  
  15. local function Login()
  16. term.setCursorPos(10 , 10)
  17. print("Username:")
  18. term.setCursorPos(10 , 11)
  19. print("Password:")
  20. term.setCursorPos(20 , 10)
  21. User = read()
  22. term.setCursorPos(20 , 11)
  23. Pass = read("*")
  24. end
  25.  
  26. local function Check()
  27. if fs.exists("Users/"..User) == true then
  28. h = fs.open("Users/"..User, "r")
  29. A = h.readAll() else
  30. Reset()
  31. term.setCursorPos(10 , 10)
  32. textutils.slowPrint("User does not exist")
  33. sleep(3)
  34. term.setCursorPos(10 , 10)
  35. term.clearLine()
  36. Login()
  37. end
  38. end
  39.  
  40. local function Verify()
  41. if A == Pass then
  42. Reset()
  43. term.setCursorPos(45 , 1)
  44. term.setTextColor(colors.green)
  45. print(""..User)
  46. term.setBackgroundColor(colors.blue)
  47. term.setTextColor(colors.white)
  48. term.setCursorPos(10 , 10) else
  49. Reset()
  50. term.setCursorPos(10 , 10)
  51. textutils.slowPrint("Incorrect password")
  52. sleep(2)
  53. term.setCursorPos(10 , 10)
  54. term.clearLine()
  55. shell.run("Client.lua")
  56. end
  57. end
  58.  
  59. local function Initialize()
  60. print("Begin Init Debug")
  61. sleep(2)
  62. local h = fs.open("Init.lua", "r")
  63. Init = h.readAll()
  64. h.close()
  65. print("Init Read File")
  66. sleep(2)
  67. if Init == "positive" then
  68. term.setCursorPos(1 , 8)
  69. textutils.slowPrint("Enter new credentials")
  70. sleep(2)
  71. Login()
  72. if fs.exists("Users/"..User) == true then
  73. Reset()
  74. term.setCursorPos(10 , 10)
  75. textutils.slowPrint("Invalid Username")
  76. sleep(2)
  77. Reset()
  78. Initialize() else
  79. h = fs.open("Users/"..User , "w")
  80. h.writeLine(""..Pass)
  81. h.close()
  82. Reset()
  83. term.setCursorPos(7 ,10)
  84. textutils.slowPrint("Computer will reboot to load credentials")
  85. sleep(3)
  86. fs.delete("Init.lua")
  87. local h = fs.open("Init.lua" , "w")
  88. h.writeLine("false")
  89. shell.run("reboot")
  90. end
  91. end
  92. end
  93.  
  94. Reset()
  95. Initialize()
  96. Login()
  97. Check()
  98. Verify()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement