Advertisement
Guest User

login

a guest
Oct 9th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.95 KB | None | 0 0
  1. local tx, ty = term.getSize()
  2. reading = "false"
  3. name = ""
  4. pass = ""
  5. passHid = ""
  6. passHide = ""
  7. x = 0
  8. y = 0
  9. while true do
  10. if os.time() <= 7 then
  11.   timeColour = colors.cyan
  12.   timeColourb = colors.gray
  13. elseif os.time() >= 19 then
  14.   timeColour = colors.cyan
  15.   timeColourb = colors.gray
  16. else
  17.   timeColour = colors.lightBlue
  18.   timeColourb = colors.white
  19. end
  20. function draw()
  21. while true do
  22. sleep(0)
  23. if reading ~= "true" then
  24. ks.clear()
  25. ks.setBackgroundColor(timeColour)
  26. term.setTextColor(colors.blue)
  27. term.setBackgroundColor(timeColour)
  28. write("HydrOS ".._HYDROSVERNUM)
  29. paintutils.drawLine(1,2,tx,2,colors.black)
  30. paintutils.drawLine(6,2,6,ty,colors.black)
  31. term.setTextColor(colors.black)
  32. term.setBackgroundColor(colors.black)
  33. basic.drawLine(1,2,tx,2)
  34. basic.drawLine(6,2,6,ty)
  35. term.setBackgroundColor(timeColour)
  36. term.setTextColor(colors.blue)
  37. basic.drawLine(2,math.floor(ty/2)-1,2,math.floor(ty/2)+1)
  38. basic.drawPixel(3,math.floor(ty/2))
  39. basic.drawLine(4,math.floor(ty/2)-1,4,math.floor(ty/2)+1)
  40. paintutils.drawLine(2,math.floor(ty/2)-1,2,math.floor(ty/2)+1,colors.blue)
  41. paintutils.drawPixel(3,math.floor(ty/2),colors.blue)
  42. paintutils.drawLine(4,math.floor(ty/2)-1,4,math.floor(ty/2)+1,colors.blue)
  43. paintutils.drawBox(8,4,tx-1,6,colors.blue)
  44. basic.drawBox(8,4,tx-1,6)
  45. paintutils.drawLine(9,5,tx-2,5,timeColourb)
  46. term.setBackgroundColor(timeColourb)
  47. term.setCursorPos(9,5)
  48. write(name)
  49. term.setBackgroundColor(timeColour)
  50. term.setCursorPos(8,3)
  51. print("Username")
  52. paintutils.drawBox(8,8,tx-1,10,colors.blue)
  53. basic.drawBox(8,8,tx-1,10)
  54. paintutils.drawLine(9,9,tx-2,9,timeColourb)
  55. term.setCursorPos(9,9)
  56. term.setBackgroundColor(timeColourb)
  57. write(passHid)
  58. term.setCursorPos(8,7)
  59. term.setBackgroundColor(timeColour)
  60. print("Password")
  61. term.setCursorPos(tx,1)
  62. term.setBackgroundColor(colors.red)
  63. term.setTextColor(colors.white)
  64. write("X")
  65. term.setCursorPos(tx-1,1)
  66. term.setBackgroundColor(colors.orange)
  67. write("O")
  68. paintutils.drawFilledBox(8,15,10,17,colors.lime)
  69. term.setTextColor(colors.lime)
  70. basic.drawFilledBox(8,15,10,17)
  71. term.setCursorPos(9,16)
  72. term.setTextColor(colors.white)
  73. write(">")
  74. term.setCursorPos(tx-10,ty)
  75. term.setBackgroundColor(timeColour)
  76. term.setTextColor(colors.blue)
  77. write("X:"..x.."Y:"..y)
  78. term.setBackgroundColour(timeColour)
  79. term.setTextColour(colors.blue)
  80. term.setCursorPos(tx/2,ty/2)
  81. end
  82. end
  83. end
  84.  sleep(0)
  85.   function time()
  86.     while true do
  87.       sleep(0)
  88.       local time = textutils.formatTime(os.time(),true)
  89.       local len = string.len(time)
  90.       if reading ~= "true" then
  91.         term.setTextColour(colors.blue)
  92.         ks.center(time,1)
  93.       end
  94.     end
  95.   end
  96.   function updater()
  97.     while true do
  98.     if reading ~= "true" then
  99.       sleep(0)
  100.       break
  101.     end
  102.     sleep(0)
  103.     end
  104.   end
  105.   function getInput()
  106.     reading = "true"
  107.     if x <= tx-1 and x >= 8 and y <= 6 and y >= 4 then
  108.       term.setBackgroundColour(timeColourb)
  109.       term.setCursorPos(9,5)
  110.       name = read()
  111.       return
  112.     elseif x <= tx-1 and x >= 8 and y >= 8 and y <= 10 then
  113.       term.setBackgroundColour(timeColourb)
  114.       term.setCursorPos(9,9)
  115.       pass = read("*")
  116.       for i =1,string.len(pass) do
  117.         passHide = passHide.."*"
  118.       end
  119.       passHid = passHide
  120.       return
  121.     end
  122.   end
  123.   function click()
  124.     local event, button, x2, y2 = os.pullEvent("mouse_click")
  125.     if x2 >= tx-1 and x2 <= 8 and y2 >= 6 and y2 <= 4 then
  126.       os.queueEvent("key",28)
  127.     elseif x2 >= tx-1 and x2 <= 8 and y2 >= 8 and y2 <= 10 then
  128.       os.queueEvent("key",28)
  129.     elseif x2 <= tx-1 and x2 >=8 and y2 <= 6 and y2 >= 4 then
  130.       x = x2
  131.       y = y2
  132.       parallel.waitForAny(getInput,click)
  133.       return
  134.     else
  135.       x = x2
  136.       y = y2
  137.       parallel.waitForAny(getInput,click)
  138.       return
  139.     end
  140.   end
  141.   function wait()
  142.     event, button, x, y = os.pullEvent("mouse_click")
  143.     if button == 1 then
  144.       if x <= tx-1 and x >= 8 and y <= 6 and y >= 4 then
  145.         parallel.waitForAny(getInput,click)
  146.         reading = "false"
  147.       elseif x <= tx-1 and x >=8 and y <= 10 and y >= 8 then
  148.         parallel.waitForAny(getInput,click)
  149.         reading = "false"
  150.       elseif x == tx and y == 1 then
  151.         os.shutdown()
  152.       elseif x == tx-1 and y == 1 then
  153.         os.reboot()
  154.       elseif x < 11 and x > 7 and y > 14 and y < 18 then
  155.         local User = fs.open("HydrOS/user/name","r")
  156.         local Pass = fs.open("HydrOS/user/pass","r")
  157.         local CUser = User.readLine()
  158.         local CPass = Pass.readLine()
  159.         if CUser == User and CPass == Pass then
  160.           os.shutdown()
  161.           shell.run("HydrOS/user/desktop")
  162.         end
  163.       end
  164.     end
  165.   end
  166.   parallel.waitForAny(wait,draw,time,updater)
  167. end
  168. ks.clear()
  169. ks.setBackgroundColor(colors.white)
  170. sleep(0.5)
  171. ks.setBackgroundColor(colors.lightBlue)
  172. sleep(0.5)
  173. ks.setBackgroundColor(colors.cyan)
  174. sleep(0.5)
  175. ks.setBackgroundColor(colors.blue)
  176. sleep(0.5)
  177. ks.setBackgroundColor(colors.gray)
  178. sleep(0.5)
  179. os.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement