Advertisement
RavenOS

rSettingsTest

Apr 2nd, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. f = fs.open("rSettings/useAdmin", "r")
  2. useAdmin = f.readLine()
  3. f.close()
  4.  
  5. term.setTextColor(colors.white)
  6. term.setBackgroundColor(colors.cyan)
  7. term.clear()
  8. term.setCursorPos(1,1)
  9. print("Settings|")
  10. print("---------")
  11. term.setCursorPos(51, 1)
  12. print("X")
  13.  
  14. if fs.exists("rSettings/doNotLogin") then
  15. term.setCursorPos(1,6)
  16. write("Use Login [ ]")
  17. else
  18. term.setCursorPos(1,6)
  19. write("Use Login [X]")
  20. end
  21.  
  22. if useAdmin == "true" then
  23. term.setCursorPos(1,8)
  24. write("Use Admin [X]")
  25. else
  26. term.setCursorPos(1,8)
  27. write("Use Admin [ ]")
  28. end
  29.  
  30. term.setCursorPos(1,4)
  31. write("Change Username/Password")
  32.  
  33. if useAdmin == "true" then
  34. term.setCursorPos(1,8)
  35. write("Use Admin [X]")
  36. else
  37. term.setCursorPos(1,8)
  38. write("Use Admin [ ]")
  39. end
  40.  
  41. while true do
  42. event, button, x, y = os.pullEvent("mouse_click")
  43.  
  44. if button == 1 then
  45. if x == 51 and y == 1 then
  46. shell.run("rOS/desktop")
  47. break
  48. elseif x == 12 and y == 8 then
  49. f = fs.open("rSettings/useAdmin", "r")
  50. useAdmin = f.readLine()
  51. f.close()
  52.  
  53. if useAdmin == "true" then
  54. f = fs.open("rSettings/useAdmin", "w")
  55. f.writeLine("false")
  56. f.close()
  57. term.setCursorPos(1,8)
  58. write("Use Admin [ ]")
  59. else
  60. f = fs.open("rSettings/useAdmin", "w")
  61. f.writeLine("true")
  62. f.close()
  63. term.setCursorPos(1,8)
  64. write("Use Admin [X]")
  65. end
  66. elseif x <= 24 and y == 4 then
  67. w, h = term.getSize()
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. print("Change Password|")
  71. print("----------------")
  72. text.center("New Username: ", -1)
  73. text.center("New Password: ", 1)
  74. term.setCursorPos(32, 8)
  75. newusername = read()
  76. term.setCursorPos(32, 10)
  77. newpassword = read()
  78. f = fs.open("rSettings/username", "w")
  79. f.writeLine(newusername)
  80. f.close()
  81. f = fs.open("rSettings/password", "w")
  82. f.writeLine(newpassword)
  83. f.close()
  84. shell.run("rPrograms/settings")
  85. break
  86. elseif x == 12 and y == 6 then
  87. if fs.exists("rSettings/doNotLogin") then
  88. fs.delete("rSettings/doNotLogin")
  89. term.setCursorPos(1,6)
  90. write("Use Login [X]")
  91. else
  92. fs.copy("temp", "rSettings/doNotLogin")
  93. term.setCursorPos(1,6)
  94. write("Use Login [ ]")
  95. end
  96. end
  97. end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement