Siftos31

settings.lua

Feb 2nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.28 KB | None | 0 0
  1. oldPull = os.pullEvent;
  2. os.pullEvent = os.pullEventRaw;
  3.  
  4. --Information about the OS is stored here--
  5. version = 0.8
  6.  
  7. --Variables
  8. w, h = term.getSize()
  9.  
  10. ---Colors
  11. blue = colors.blue
  12. black = colors.black
  13. white = colors.white
  14. red = colors.red
  15. yellow = colors.yellow
  16. lightBlue = colors.lightBlue
  17. lightGray = colors.lightGray
  18. green = colors.green
  19. lime = colors.lime
  20. pink = colors.pink
  21. purple = colors.purple
  22. magenta = colors.magenta
  23. gray = colors.gray
  24. brow = colors.brown
  25. cyan = colors.cyan
  26. orange = colors.orange
  27.  
  28. --Functions
  29. function clear()
  30. term.clear()
  31. end
  32.  
  33. function setBackgroundColor(...)
  34. term.setBackgroundColor(...)
  35. term.clear()
  36. end
  37.  
  38. function clearLine(y, c)
  39. term.setCursorPos(1,y)
  40. term.setBackgroundColor(c)
  41. term.clearLine()
  42. end
  43.  
  44. function setTextColor(...)
  45. term.setTextColor(...)
  46. end
  47.  
  48. function printCenter(y, s)
  49. local x = math.floor((w - string.len(s))/2)
  50. term.setCursorPos(x,y)
  51. write(s)
  52. end
  53.  
  54. function slowPrint(...)
  55. textutils.slowPrint(...)
  56. end
  57.  
  58. function slowWrite(...)
  59. textutils.slowWrite(...)
  60. end
  61.  
  62. function setCursorPos(x, y)
  63. term.setCursorPos(x,y)
  64. end
  65.  
  66. function background(...)
  67. term.setBackgroundColor(...)
  68. end
  69.  
  70. function drawImage(x,y,s)
  71. paintutils.drawImage(paintutils.loadImage(s),x,y)
  72. end
  73.  
  74. --Program starts
  75. oldPull = os.pullEvent;
  76. os.pullEvent = os.pullEventRaw;
  77.  
  78. sett = true
  79. animation = true
  80. bc = lightBlue
  81. _x = 4
  82. tmsts = 0
  83. local buc = white
  84. local tc = black
  85. local main = true
  86. local _num = 0
  87. local _tm = 0
  88. function _update()
  89. _open = fs.open("/privacy/password","r")
  90. opw = tostring(_open.readLine())
  91. _open.close()
  92. end
  93. _update()
  94. local pwc = {}
  95. pwc[1] = false
  96. pwc[2] = false
  97. pwc[3] = false
  98.  
  99. function slide()
  100. drawDesktop()
  101. repeat
  102. _x = _x + 8
  103. drawImage(_x, 2,"/swfiles/animations/window")
  104. sleep(0.03)
  105. drawDesktop()
  106. until _x >= 52
  107. bc = white
  108. drawDesktop()
  109. shell.run("/swfiles/ACEOS.lua")
  110. end
  111.  
  112. function drawDesktop()
  113. setBackgroundColor(bc)
  114. clearLine(19,lightGray)
  115. background(buc)
  116. setTextColor(tc)
  117. setCursorPos(1,19)
  118. write("[|]")
  119. end
  120.  
  121. function drawSetting()
  122. if animation == true then
  123. drawDesktop()
  124. drawImage(1,1,"/swfiles/animations/window2")
  125. sleep(0.1)
  126. drawDesktop()
  127. drawImage(1,1,"/swfiles/animations/window3")
  128. sleep(0.1)
  129. drawDesktop()
  130. drawImage(4,2,"/swfiles/animations/window")
  131. elseif animation == false then
  132. drawDesktop()
  133. drawImage(4,2,"/swfiles/animations/window")
  134. end
  135. if tmsts == 0 then
  136.   background(red)
  137.   setTextColor(white)
  138.   setCursorPos(47,2)
  139.   print("x")
  140.   setCursorPos(5, 2)
  141.   background(lightGray)
  142.   setTextColor(gray)
  143.   print("Settings")
  144.   setCursorPos(5, 4)
  145.   setTextColor(blue)
  146.   background(white)
  147.   print("Users")
  148. elseif tmsts == 1 then
  149.   background(red)
  150.   setTextColor(white)
  151.   setCursorPos(47,2)
  152.   print("x")
  153.   setCursorPos(5,2)
  154.   background(lightGray)
  155.   setTextColor(gray)
  156.   print("Settings/Users")
  157.   setCursorPos(43,2)
  158.   print("<--")
  159.   setCursorPos(5,4)
  160.   setTextColor(blue)
  161.   background(white)
  162.   print("Change username")
  163.   setCursorPos(5,5)
  164.   print("Change password")
  165. end
  166. end
  167.  
  168. function drawPopupUN()
  169.   setCursorPos(20,4)
  170.   setTextColor(gray)
  171.   background(lightGray)
  172.   print("Popup")
  173.   setCursorPos(32,4)
  174.   setTextColor(white)
  175.   background(red)
  176.   print("x")
  177.   background(white)
  178.   setTextColor(black)
  179.   setCursorPos(20,5)
  180.   print("Old Username:")
  181.   local h = fs.open("/privacy/username","r")
  182.   local oun = h.readLine()
  183.   h.close()
  184.   setCursorPos(22,6)
  185.   background(lightBlue)
  186.   print(oun)
  187.   setCursorPos(20,7)
  188.   background(white)
  189.   print("New Username:")
  190. end
  191.  
  192. function drawPopupPS()
  193.   setCursorPos(20,4)
  194.   setTextColor(gray)
  195.   background(lightGray)
  196.   print("Popup")
  197.   setCursorPos(32,4)
  198.   setTextColor(white)
  199.   background(red)
  200.   print("x")
  201.   background(white)
  202.   setTextColor(black)
  203.   setCursorPos(20,5)
  204.   print("Old Password:")
  205.   setCursorPos(20,7)
  206.   print("New Password:")
  207.   setCursorPos(20,9)
  208.   print("Repeat:")
  209. end
  210.  
  211. drawSetting()
  212. --Loop
  213. while sett == true do
  214. local event, button, X, Y = os.pullEventRaw()
  215. if event == "mouse_click" then
  216.   if main == true then
  217.   if X==47 and Y==2 and button == 1 then
  218.   drawDesktop()
  219.   drawImage(1,1,"/swfiles/animations/window3")
  220.   sleep(0.1)
  221.   drawDesktop()
  222.   drawImage(1,1,"/swfiles/animations/window2")
  223.   sleep(0.1)
  224.   drawDesktop()
  225.   shell.run("/swfiles/ACEOS.lua")
  226.   break
  227.   end
  228.   if X>=1 and X<=52 and Y==1 and button == 1 then
  229.   slide()
  230.   break
  231.   elseif X>=1 and X<=3 and Y>=1 and Y<=19 and button == 1 then
  232.   slide()
  233.   break
  234.   elseif X>=1 and X<=52 and Y>=17 and Y<=19 and button == 1 then
  235.   slide()
  236.   break
  237.   elseif X>=48 and X<=52 and Y>=1 and Y<=19 and button == 1 then
  238.   slide()
  239.   break
  240.   end
  241.   end
  242.   if tmsts == 0 then
  243.     if X>=5 and X<=10 and Y==4 and button==1 then
  244.       background(lightBlue)
  245.       setCursorPos(5,4)
  246.       setTextColor(white)
  247.       print("Users")
  248.       pcall(sleep,0.1)
  249.       tmsts = 1
  250.       animation = false
  251.       drawSetting()
  252.       animation = true
  253.     end
  254.   elseif tmsts == 1 then
  255.     if X>=43 and X<=45 and Y==2 and button == 1 then
  256.       animation = false
  257.       tmsts = 0
  258.       drawSetting()
  259.       animation = true
  260.     elseif X>=5 and X<=20 and Y==4 and button == 1 then
  261.       setCursorPos(5,4)
  262.       background(lightBlue)
  263.       setTextColor(white)
  264.       print("Change username")
  265.       sleep(0.1)
  266.       setBackgroundColor(black)
  267.       drawImage(20,4,"/swfiles/animations/popup")
  268.       drawPopupUN()
  269.       main = false
  270.       tmsts = 2
  271.     elseif X>=5 and X<=20 and Y==5 and button == 1 then
  272.       setCursorPos(5,5)
  273.       background(lightBlue)
  274.       setTextColor(white)
  275.       print("Change password")
  276.       sleep(0.1)
  277.       setBackgroundColor(black)
  278.       drawImage(20,4,"/swfiles/animations/popup2")
  279.       drawPopupPS()
  280.       tmsts = 3
  281.     end
  282.   elseif tmsts == 2 then
  283.     if X==32 and Y==4 and button == 1 then
  284.       animation = false
  285.       tmsts = 1
  286.       main = true
  287.       drawSetting()
  288.       animation = true
  289.     elseif X>=22 and X<=31 and Y==8 and button == 1 then
  290.       setCursorPos(22,8)
  291.       background(lightBlue)
  292.       setTextColor(black)
  293.       local user = read()
  294.        if user == "" then
  295.         user = " "
  296.        end
  297.       local _u = fs.open("/privacy/username","w")
  298.       _u.write(user)
  299.       _u.close()
  300.       animation = false
  301.       tmsts = 1
  302.       main = true
  303.       drawSetting()
  304.       animation = true
  305.     end
  306.   elseif tmsts == 3 then
  307.   if X>=21 and X<=31 and Y==6 and button == 1 then
  308.     _num = 0
  309.     if _num == 0 then
  310.     setCursorPos(21,6)
  311.     background(lightBlue)
  312.     write("           ")
  313.     setCursorPos(20,11)
  314.     background(white)
  315.     setTextColor(red)
  316.     print("             ")
  317.     background(lightBlue)
  318.     setTextColor(gray)
  319.     setCursorPos(21,6)
  320.     _pass = read("*")
  321.       if _pass == opw then
  322.         _num = 1
  323.         pwc[1] = true
  324.         if pwc[1] == true and pwc[2] == true and pwc[3] == true then
  325.           local np = fs.open("/privacy/password","w")
  326.           np.write(_npass)
  327.           np.close()
  328.           animation = false
  329.           tmsts = 1
  330.           drawSetting()
  331.           animation = true
  332.           pwc = {false,false,false}
  333.           _update()
  334.         end
  335.       else
  336.         _num = 0
  337.         background(lightBlue)
  338.         setCursorPos(21,6)
  339.         write("          ")
  340.         setTextColor(red)
  341.         background(white)
  342.         setCursorPos(20,11)
  343.         print("Wrong O.PWord")
  344.       end
  345.     end
  346.   elseif X>=21 and X<=31 and Y==8 and button == 1 then
  347.     setCursorPos(21,8)
  348.     background(lightBlue)
  349.     write("           ")
  350.     setCursorPos(20,11)
  351.     background(white)
  352.     setTextColor(red)
  353.     print("             ")
  354.     setCursorPos(21,8)
  355.     background(lightBlue)
  356.     setTextColor(gray)
  357.     _npass = read("*")
  358.     if string.len(_npass) >= 9 then
  359.       setTextColor(red)
  360.       background(white)
  361.       setCursorPos(20,11)
  362.       print("Only 8 chara.")
  363.       setCursorPos(21,8)
  364.       background(lightBlue)
  365.       write("           ")
  366.       pwc[2] = false
  367.     else
  368.     pwc[2] = true
  369.     end
  370.   elseif X>=21 and X<=31 and Y==10 and button == 1 then
  371.     setCursorPos(21,10)
  372.     background(lightBlue)
  373.     write("           ")
  374.     setCursorPos(20,11)
  375.     background(white)
  376.     setTextColor(red)
  377.     print("             ")
  378.     setCursorPos(21,10)
  379.     background(lightBlue)
  380.     setTextColor(gray)
  381.     _rpass = read("*")
  382.     if string.len(_rpass) >= 9 then
  383.       setTextColor(red)
  384.       background(white)
  385.       setCursorPos(20,11)
  386.       print("Only 8 chara.")
  387.       setCursorPos(21,8)
  388.       background(lightBlue)
  389.       write("           ")
  390.       pwc[2] = false
  391.     else
  392.     if _npass == _rpass then
  393.       pwc[3] = true
  394.       if pwc[1] == true and pwc[2] == true and pwc[3] == true then
  395.         local np = fs.open("/privacy/password","w")
  396.         np.write(_npass)
  397.         np.close()
  398.         animation = false
  399.         tmsts = 1
  400.         drawSetting()
  401.         animation = true
  402.         pwc = {false,false,false}
  403.         _update()
  404.       end
  405.     else
  406.       background(lightBlue)
  407.       setCursorPos(21,10)
  408.       write("           ")
  409.       background(white)
  410.       setTextColor(red)
  411.       setCursorPos(20,11)
  412.       print("Wrong repeat")
  413.       pwc[3] = false
  414.     end
  415.     end
  416.   elseif X==32 and Y==4 and button == 1 then
  417.     animation = false
  418.     tmsts = 1
  419.     drawSetting()
  420.     animation = true
  421.   end
  422.   end
  423. end
  424. end
  425.  
  426. os.pullEvent = oldPull;
Add Comment
Please, Sign In to add comment