Guest User

test

a guest
Jan 3rd, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.57 KB | None | 0 0
  1. Username = "Username"
  2. Password = "Password"
  3. local Hint = "[Insert Hint Here]"
  4. local function readN(len, replaceChar)
  5.   len = len or 18
  6.   local input = ""
  7.   local key = 0
  8.   term.setCursorBlink(true)
  9.   repeat
  10.         local e,p1 = os.pullEvent()
  11.         if e == "char" then
  12.           if #input < len then
  13.             input = input..p1
  14.             term.write(replaceChar or p1)
  15.           end
  16.         elseif e == "key" and p1==keys.backspace and #input > 0 then
  17.           input = input:sub(1,#input-1)
  18.           local x,y = term.getCursorPos()
  19.           term.setCursorPos(x-1,y)
  20.           term.write(" ")
  21.           term.setCursorPos(x-1,y)
  22.         end
  23.   until p1==keys.enter
  24.   term.setCursorBlink(false)
  25.   return input
  26. end
  27. local version = "v1.3"
  28. term.clear()
  29. term.setCursorPos(13,7)
  30. term.setTextColor(colors.purple)
  31. print("EnderOS "..version.." Initializing")
  32. term.setTextColor(colors.white)
  33. term.setBackgroundColor(colors.lime)
  34. for i = 14, 36 do
  35.   term.setCursorPos(i,9)
  36.   term.write(" ")
  37.   sleep(0.3)
  38. end
  39. term.setBackgroundColor(colors.black)
  40. sleep(1)
  41. function screen()
  42. term.clear()
  43. term.setCursorPos(1,1)
  44. term.setTextColor(colors.lime)
  45. print("+-------------------------------------------------+")
  46. print("|                                                 |")
  47. print("|                 ")
  48. term.setCursorPos(19,3)
  49. term.setTextColor(colors.purple)
  50. print("EnderOS v1.3")
  51. term.setTextColor(colors.lime)
  52. term.setCursorPos(31,3)
  53. print("                    |")
  54. print("|                                                 |")
  55. print("|                                                 |")
  56. print("|                                                 |")
  57. print("|                                                 |")
  58. print("|        ")
  59. term.setCursorPos(10,8)
  60. term.setTextColor(colors.orange)
  61. print("Username:")
  62. term.setCursorPos(19,8)
  63. print("                               ")
  64. term.setCursorPos(50,8)
  65. term.setTextColor(colors.lime)
  66. print(" |")
  67. print("|                                                 |")
  68. print("|        ")
  69. term.setTextColor(colors.orange)
  70. term.setCursorPos(10,10)
  71. print("Password:")
  72. term.setCursorPos(19,10)
  73. print("                               ")
  74. term.setCursorPos(50,10)
  75. term.setTextColor(colors.lime)
  76. print(" |")
  77. print("|                                                 |")
  78. print("|                                                 |")
  79. print("|     ")
  80. term.setCursorPos(8,13)
  81. term.setTextColor(colors.blue)
  82. print("forgot password                      ")
  83. term.setCursorPos(50,13)
  84. term.setTextColor(colors.lime)
  85. print(" |")
  86. print("|                                                 |")
  87. print("|                                                 |")
  88. print("|                                                 |")
  89. print("|                                                 |")
  90. print("|                                                 |")
  91. term.write("+-------------------------------------------------+")
  92. end
  93. screen()
  94. function click()
  95. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  96.   if button == 1 then
  97.     if (xPos >= 8 and xPos <= 22 and yPos == 13) then
  98.       term.setCursorPos(10,14)
  99.       print("Hint: "..Hint)
  100.       click()
  101.     elseif (xPos >=10 and xPos <= 18 and yPos == 8) then
  102.       term.setCursorPos(20,8)
  103.     else
  104.       click()
  105.     end
  106.   else
  107.     screen()
  108.     click()
  109.   end
  110. end
  111. function login()
  112. click()
  113. term.setTextColor(colors.white)
  114. input = read()
  115. if input == (Username) then
  116.   term.setCursorPos(8,8)
  117.   term.setTextColor(colors.lime)
  118.   term.write("O")
  119.   term.setTextColor(colors.white)
  120.   term.setCursorPos(20,10)
  121.   input = read()
  122.     if input == (Password) then
  123.       term.setCursorPos(8,10)
  124.       term.setTextColor(colors.lime)
  125.       term.write("O")
  126.       term.setTextColor(colors.white)
  127.       sleep(0.8)
  128.       term.clear()
  129.       term.setCursorPos(20,8)
  130.       print("Logging in")
  131.       term.setCursorPos(30,8)
  132.       sleep(0.7)
  133.       print(".")
  134.       sleep(0.7)
  135.       term.setCursorPos(31,8)
  136.       print(".")
  137.       sleep(0.7)
  138.       term.setCursorPos(32,8)
  139.       print(".")
  140.       sleep(0.7)
  141.       term.clear()
  142.       term.setCursorPos(1,1)
  143.       term.setTextColor(colors.purple)
  144.       term.write("EnderOS "..version)
  145.       term.setCursorPos(1,2)
  146.     else
  147.       term.setCursorPos(8,10)
  148.       term.setTextColor(colors.red)
  149.       term.write("X")
  150.       sleep(0.5)
  151.       term.setTextColor(colors.white)
  152.       screen()
  153.       login()
  154.     end
  155. else
  156.   term.setCursorPos(8,8)
  157.   term.setTextColor(colors.red)
  158.   term.write("X")
  159.   sleep(0.5)
  160.   term.setTextColor(colors.white)
  161.   screen()
  162.   login()
  163. end
  164. end
  165. login()
Advertisement
Add Comment
Please, Sign In to add comment