-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexPassword
More file actions
117 lines (107 loc) · 2.95 KB
/
exPassword
File metadata and controls
117 lines (107 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
-- Thanks for use the program
--by Xia_ST
term.setTextColor(colors. white)
local button = {}
term.setBackgroundColor(colors.black)
local password = "1024"
local input = ""
function setTable(name, func, xmin, xmax, ymin, ymax)
button[name] = {}
button[name]["func"] = func
button[name]["active"] = false
button[name]["xmin"] = xmin
button[name]["ymin"] = ymin
button[name]["xmax"] = xmax
button[name]["ymax"] = ymax
end
function heading(text)
w, h = term.getSize()
term.setCursorPos((w-string.len(text))/2+1, 1)
term.write(text)
end
function func(arg)
if arg>='0' and arg<= '9' then
input = input .. arg
elseif arg == 'C' then
input = ""
elseif arg == 'E' then
if input == password then
heading (" ")
heading("Welcome back, Master!")
input = ""
rs.setOutput("bottom", true)
sleep(5)
rs.setOutput("bottom",false)
heading(" ")
heading("Please input the password")
else
heading (" ")
heading("wrong password")
input = ""
sleep(1)
heading(" ")
heading("Please input the password")
end
end
end
function fillTable()
setTable("7", func, 18, 22, 3, 5)
setTable("8", func, 24, 28, 3, 5)
setTable("9", func, 30, 34, 3, 5)
setTable("4", func, 18, 22, 7, 9)
setTable("5", func, 24, 28, 7, 9)
setTable("6", func, 30, 34, 7, 9)
setTable("1", func, 18, 22, 11, 13)
setTable("2", func, 24, 28, 11, 13)
setTable("3", func, 30, 34, 11, 13)
setTable("C", func, 18, 22, 15, 17)
setTable("0", func, 24, 28, 15, 17)
setTable("E", func, 30, 34, 15, 17)
end
function fill(text, color, bData)
term.setBackgroundColor(color)
local yspot = math.floor((bData["ymin"]+bData["ymax"])/2)
local xspot = math.floor((bData["xmax"]-bData["xmin"]-string.len(text))/2+1)
for j = bData["ymin"], bData["ymax"] do
term.setCursorPos(bData["xmin"], j)
if j == yspot then
for k = 0, bData["xmax"]-bData["xmin"]-string.len(text)+1 do
if k == xspot then
term.write(text)
else
term.write(" ")
end
end
else
for i = bData["xmin"], bData["xmax"] do
term.write(" ")
end
end
end
term.setBackgroundColor(colors.black)
end
function screen()
local currColor
for name, data in pairs(button) do
currColor = colors.lime
fill(name, currColor, data)
end
end
function checkxy(x, y)
for name, data in pairs(button) do
if y>=data["ymin"] and y<=data["ymax"] then
if x>=data["xmin"] and x<=data["xmax"] then
data["func"](name)
end
end
end
end
fillTable()
term.clear()
screen()
heading("Please input the password")
while true do
local e, side, x, y = os.pullEvent("mouse_click")
checkxy(x,y)
sleep(0.1)
end