TaZeOS

os/programs/settings/profile.lua

Nov 3rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. log("==> Loading profile menu")
  2. passwordwindow = window.create(term.current(),2,9,15,1)
  3. passwordwindow.setVisible(false)
  4. usernamewindow = window.create(term.current(),2,9,15,1)
  5. usernamewindow.setVisible(false)
  6. taskbar.setCursorPos(1,1)
  7. taskbar.write(" Settings - Profile")
  8. taskbar.setCursorPos(49,1)
  9. taskbar.setTextColor(colors.red)
  10. taskbar.write("#")
  11. taskbar.setCursorPos(48,1)
  12. taskbar.setTextColor(colors.orange)
  13. taskbar.write("#")
  14. taskbar.setTextColor(colors.white)
  15. pw = window.create(term.current(),1,2,51,18)
  16. pw.setBackgroundColor(colors.white)
  17. pw.clear()
  18.  
  19. passwordwindow.setBackgroundColor(colors.lightGray)
  20. passwordwindow.clear()
  21. passwordwindow.write("New Password")
  22.  
  23. usernamewindow.setBackgroundColor(colors.lightGray)
  24. usernamewindow.clear()
  25. usernamewindow.write("New Username")
  26.  
  27. pw.setCursorPos(2,4)
  28. pw.setBackgroundColor(colors.red)
  29. pw.write(" ")
  30. pw.setCursorPos(2,5)
  31. pw.write(" Change Password ")
  32. pw.setCursorPos(2,6)
  33. pw.write(" ")
  34. pw.setCursorPos(20,4)
  35. pw.write(" ")
  36. pw.setCursorPos(20,5)
  37. pw.write(" Change Username ")
  38. pw.setCursorPos(20,6)
  39. pw.write(" ")
  40.  
  41.  
  42.  
  43. while true do
  44.  
  45. local event, button, x, y = os.pullEvent("mouse_click")
  46.  
  47.  
  48.  
  49. if x == 48 and y == 1 then
  50. skip = "yes"
  51. shell.run('OS/programs/settings/start.lua')
  52.  
  53. elseif x == 49 and y == 1 then
  54. shell.run('OS/desktop.lua')
  55. elseif x >= 2 and x <= 18 and y >= 5 and y <= 7 then
  56. passwordwindow.setVisible(true)
  57. os.pullEvent("key")
  58. passwordwindow.setBackgroundColor(colors.lightGray)
  59. passwordwindow.clear()
  60. scp(2,9)
  61. term.setBackgroundColor(colors.lightGray)
  62. newpassword = read()
  63. checkCurrentUserId()
  64. logincheck = fs.open("OS/Users/"..userid.."/info.data", "r")
  65. if logincheck then
  66. username1 = logincheck.readLine()
  67. userpass1 = logincheck.readLine()
  68. admin = logincheck.readLine()
  69. logincheck.close()
  70. end
  71.  
  72. newlogincheck = fs.open("OS/Users/"..userid.."/info.data", "w")
  73. if newlogincheck then
  74. newlogincheck.writeLine(username1)
  75. newlogincheck.writeLine(newpassword)
  76. newlogincheck.writeLine(admin)
  77. newlogincheck.close()
  78. end
  79.  
  80. elseif x >= 20 and x <= 36 and y >= 4 and y <= 7 then
  81. usernamewindow.setVisible(true)
  82. checkCurrentUserId()
  83. os.pullEvent("key")
  84. usernamewindow.setBackgroundColor(colors.lightGray)
  85. usernamewindow.clear()
  86. scp(2,9)
  87. term.setBackgroundColor(colors.lightGray)
  88. newusername = read()
  89.  
  90. logincheck = fs.open("OS/Users/"..userid.."/info.data", "r")
  91. if logincheck then
  92. username1 = logincheck.readLine()
  93. userpass1 = logincheck.readLine()
  94. admin = logincheck.readLine()
  95. logincheck.close()
  96. end
  97.  
  98. newlogincheck = fs.open("OS/Users/"..userid.."/info.data", "w")
  99. if newlogincheck then
  100. newlogincheck.writeLine(newusername)
  101. newlogincheck.writeLine(userpass1)
  102. newlogincheck.writeLine(admin)
  103. newlogincheck.close()
  104. end
  105.  
  106. end
  107. end
Add Comment
Please, Sign In to add comment