View difference between Paste ID: 71fVfNN5 and Z0v0tkFp
SHOW: | | - or go back to the newest paste.
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
os.pullEvent = os.pullEventRaw
28
local version = "v1.3"
29
term.clear()
30
term.setCursorPos(13,7)
31
term.setTextColor(colors.purple)
32
print("EnderOS "..version.." Initializing")
33
term.setTextColor(colors.white)
34
term.setBackgroundColor(colors.lime)
35
for i = 14, 36 do
36
  term.setCursorPos(i,9)
37
  term.write(" ")
38
  sleep(0.3)
39
end
40
term.setBackgroundColor(colors.black)
41
sleep(1)
42
function screen()
43
term.clear()
44
term.setCursorPos(1,1)
45
term.setTextColor(colors.lime)
46
print("+-------------------------------------------------+")
47
print("|                                                 |")
48
print("|                 ")
49
term.setCursorPos(19,3)
50
term.setTextColor(colors.purple)
51
print("EnderOS v1.3")
52
term.setTextColor(colors.lime)
53
term.setCursorPos(31,3)
54
print("                    |")
55
print("|                                                 |")
56
print("|                                                 |")
57
print("|                                                 |")
58
print("|                                                 |")
59
print("|        ")
60
term.setCursorPos(10,8)
61
term.setTextColor(colors.orange)
62
print("Username:")
63
term.setCursorPos(19,8)
64
print("                               ")
65
term.setCursorPos(50,8)
66
term.setTextColor(colors.lime)
67
print(" |")
68
print("|                                                 |")
69
print("|        ")
70
term.setTextColor(colors.orange)
71
term.setCursorPos(10,10)
72
print("Password:")
73
term.setCursorPos(19,10)
74
print("                               ")
75
term.setCursorPos(50,10)
76
term.setTextColor(colors.lime)
77
print(" |")
78
print("|                                                 |")
79
print("|                                                 |")
80
print("|     ")
81
term.setCursorPos(8,13)
82
term.setTextColor(colors.blue)
83
print("forgot password                      ")
84
term.setCursorPos(50,13)
85
term.setTextColor(colors.lime)
86
print(" |")
87
print("|                                                 |")
88
print("|                                                 |")
89
print("|                                                 |")
90
print("|                                                 |")
91
print("|                                                 |")
92
term.write("+-------------------------------------------------+")
93
end
94
screen()
95
function click()
96
local event, button, xPos, yPos = os.pullEvent("mouse_click")
97
  if button == 1 then
98
    if (xPos >= 8 and xPos <= 22 and yPos == 13) then
99
      term.setCursorPos(10,14)
100
      print("Hint: "..Hint)
101
      click()
102
    elseif (xPos >=10 and xPos <= 18 and yPos == 8) then
103
      term.setCursorPos(20,8)
104
    else
105
      click()
106
    end
107
  else
108
    screen()
109
    click()
110
  end
111
end
112
function login()
113
click()
114
term.setTextColor(colors.white)
115
input = read()
116
if input == (Username) then
117
  term.setCursorPos(8,8)
118
  term.setTextColor(colors.lime)
119
  term.write("O")
120
  term.setTextColor(colors.white)
121
  term.setCursorPos(20,10)
122
  input = read()
123
    if input == (Password) then
124
      term.setCursorPos(8,10)
125
      term.setTextColor(colors.lime)
126
      term.write("O")
127
      term.setTextColor(colors.white)
128
      sleep(0.8)
129
      term.clear()
130
      term.setCursorPos(20,8)
131
      print("Logging in")
132
      term.setCursorPos(30,8)
133
      sleep(0.7)
134
      print(".")
135
      sleep(0.7)
136
      term.setCursorPos(31,8)
137
      print(".")
138
      sleep(0.7)
139
      term.setCursorPos(32,8)
140
      print(".")
141
      sleep(0.7)
142
      term.clear()
143
      term.setCursorPos(1,1)
144
      term.setTextColor(colors.purple)
145
      term.write("EnderOS "..version)
146
      term.setCursorPos(1,2)
147
    else
148
      term.setCursorPos(8,10)
149
      term.setTextColor(colors.red)
150
      term.write("X")
151
      sleep(0.5)
152
      term.setTextColor(colors.white)
153
      screen()
154
      login()
155
    end
156
else
157
  term.setCursorPos(8,8)
158
  term.setTextColor(colors.red)
159
  term.write("X")
160
  sleep(0.5)
161
  term.setTextColor(colors.white)
162
  screen()
163
  login()
164
end
165
end
166
login()