SHOW:
|
|
- or go back to the newest paste.
1 | - | -- DebiPassTor - (c) monster010 |
1 | + | -- by TheGameBros |
2 | - | |
2 | + | |
3 | - | |
3 | + | |
4 | - | |
4 | + | |
5 | ---------------------------------- | |
6 | ----- DONT CHANGE UNDER THIS ----- | |
7 | ---------------------------------- | |
8 | os.loadAPI("/debipasstor/api/config") | |
9 | os.loadAPI("/debipasstor/api/monster010") | |
10 | os.loadAPI("/debipasstor/api/btn") | |
11 | - | |
11 | + | |
12 | - | |
12 | + | |
13 | - | |
13 | + | |
14 | local software = "DebiPassTor" | |
15 | local monitor | |
16 | local cfg = {} | |
17 | local button = {} | |
18 | local input = "" | |
19 | local myTimer | |
20 | local xyzTimer | |
21 | local zyxTimer | |
22 | - | |
22 | + | |
23 | - | |
23 | + | |
24 | - | |
24 | + | |
25 | function addButtons() | |
26 | - | for name, data in pairs(button) do |
26 | + | for name, data in pairs(button) do |
27 | - | btn.add(name, data["name"], keyType, name, data["x"], data["y"], data["w"], data["h"], data["color"]) |
27 | + | btn.add(name, data["name"], keyType, name, data["x"], data["y"], data["w"], data["h"], data["color"]) |
28 | - | end |
28 | + | end |
29 | - | |
29 | + | |
30 | - | btn.screen() |
30 | + | btn.screen() |
31 | end | |
32 | - | |
32 | + | |
33 | function load() | |
34 | - | if fs.exists("/debipasstor/save") then |
34 | + | if fs.exists("/debipasstor/save") then |
35 | - | button = monster010.loadFile("/debipasstor/save", true) |
35 | + | button = monster010.loadFile("/debipasstor/save", true) |
36 | - | end |
36 | + | end |
37 | - | |
37 | + | |
38 | - | addButtons() |
38 | + | addButtons() |
39 | end | |
40 | - | |
40 | + | |
41 | - | |
41 | + | |
42 | - | |
42 | + | |
43 | - | |
43 | + | |
44 | function StrToNum(str) | |
45 | - | if(str == "one") then |
45 | + | if(str == "one") then |
46 | - | return 1 |
46 | + | return 1 |
47 | - | elseif(str == "two") then |
47 | + | elseif(str == "two") then |
48 | - | return 2 |
48 | + | return 2 |
49 | - | elseif(str == "dree") then |
49 | + | elseif(str == "dree") then |
50 | - | return 3 |
50 | + | return 3 |
51 | - | elseif(str == "four") then |
51 | + | elseif(str == "four") then |
52 | - | return 4 |
52 | + | return 4 |
53 | - | elseif(str == "five") then |
53 | + | elseif(str == "five") then |
54 | - | return 5 |
54 | + | return 5 |
55 | - | elseif(str == "six") then |
55 | + | elseif(str == "six") then |
56 | - | return 6 |
56 | + | return 6 |
57 | - | elseif(str == "seven") then |
57 | + | elseif(str == "seven") then |
58 | - | return 7 |
58 | + | return 7 |
59 | - | elseif(str == "eight") then |
59 | + | elseif(str == "eight") then |
60 | - | return 8 |
60 | + | return 8 |
61 | - | elseif(str == "nine") then |
61 | + | elseif(str == "nine") then |
62 | - | return 9 |
62 | + | return 9 |
63 | - | elseif(str == "null") then |
63 | + | elseif(str == "null") then |
64 | - | return 0 |
64 | + | return 0 |
65 | - | end |
65 | + | end |
66 | end | |
67 | - | |
67 | + | |
68 | function keyType(key) | |
69 | - | btn.flash(key) |
69 | + | btn.flash(key) |
70 | - | |
70 | + | |
71 | - | if(key == "enter") then |
71 | + | if(key == "enter") then |
72 | - | os.cancelTimer(myTimer) |
72 | + | os.cancelTimer(myTimer) |
73 | - | checkPW() |
73 | + | checkPW() |
74 | - | else |
74 | + | else |
75 | - | input = input..StrToNum(key) |
75 | + | input = input..StrToNum(key) |
76 | - | end |
76 | + | end |
77 | - | |
77 | + | |
78 | - | myTimer = os.startTimer(5) |
78 | + | myTimer = os.startTimer(5) |
79 | end | |
80 | - | |
80 | + | |
81 | function checkPW() | |
82 | - | if(input == cfg["password"]) then |
82 | + | if(input == cfg["password"]) then |
83 | - | rs.setBundledOutput(cfg["redSide"], colors.red) |
83 | + | rs.setOutput("left",true) |
84 | - | pwResult(true) |
84 | + | pwResult(true) |
85 | - | input = "" |
85 | + | input = "" |
86 | - | else |
86 | + | else |
87 | - | pwResult(false) |
87 | + | pwResult(false) |
88 | - | input = "" |
88 | + | input = "" |
89 | - | end |
89 | + | end |
90 | end | |
91 | - | |
91 | + | |
92 | function pwResult(success) | |
93 | - | monster010.clearMonitor() |
93 | + | monster010.clearMonitor() |
94 | - | |
94 | + | |
95 | - | local bgcolor |
95 | + | local bgcolor |
96 | - | local color = colors.white |
96 | + | local color = colors.white |
97 | - | |
97 | + | |
98 | - | local data = { |
98 | + | local data = { |
99 | - | label = "", |
99 | + | label = "", |
100 | - | xmin = 2, |
100 | + | xmin = 2, |
101 | - | ymin = 2, |
101 | + | ymin = 2, |
102 | - | xmax = 17, |
102 | + | xmax = 17, |
103 | - | ymax = 11, |
103 | + | ymax = 11, |
104 | - | } |
104 | + | } |
105 | - | |
105 | + | |
106 | - | if success == true then |
106 | + | if success == true then |
107 | - | bgcolor = colors.lime |
107 | + | bgcolor = colors.lime |
108 | - | data["label"] = "Tor freigegeben" |
108 | + | data["label"] = "Tor freigegeben" |
109 | - | else |
109 | + | else |
110 | - | bgcolor = colors.red |
110 | + | bgcolor = colors.red |
111 | - | data["label"] = "Passwort falsch" |
111 | + | data["label"] = "Passwort falsch" |
112 | - | end |
112 | + | end |
113 | - | |
113 | + | |
114 | - | btn.fill(data["label"], bgcolor, color, data) |
114 | + | btn.fill(data["label"], bgcolor, color, data) |
115 | - | |
115 | + | |
116 | - | if success == true then |
116 | + | if success == true then |
117 | - | xyzTimer = os.startTimer(5) |
117 | + | xyzTimer = os.startTimer(1) |
118 | - | else |
118 | + | else |
119 | - | rs.setBundledOutput(cfg["redSide"], colors.black) |
119 | + | rs.setBundledOutput(cfg["redSide"], colors.black) |
120 | - | zyxTimer = os.startTimer(3) |
120 | + | zyxTimer = os.startTimer(3) |
121 | - | end |
121 | + | end |
122 | end | |
123 | - | |
123 | + | |
124 | function closeTor() | |
125 | - | local bgcolor = colors.red |
125 | + | local bgcolor = colors.lime |
126 | - | local color = colors.white |
126 | + | local color = colors.white |
127 | - | |
127 | + | |
128 | - | local data = { |
128 | + | local data = { |
129 | - | label = "Tor Schliessung", |
129 | + | label = "", |
130 | - | xmin = 2, |
130 | + | xmin = 2, |
131 | - | ymin = 2, |
131 | + | ymin = 2, |
132 | - | xmax = 17, |
132 | + | xmax = 17, |
133 | - | ymax = 11, |
133 | + | ymax = 11, |
134 | - | } |
134 | + | } |
135 | - | |
135 | + | |
136 | - | btn.fill(data["label"], bgcolor, color, data) |
136 | + | btn.fill(data["label"], bgcolor, color, data) |
137 | - | rs.setBundledOutput(cfg["redSide"], colors.black) |
137 | + | rs.setOutput("left",false) |
138 | - | |
138 | + | |
139 | - | zyxTimer = os.startTimer(5) |
139 | + | zyxTimer = os.startTimer(1) |
140 | - | |
140 | + | |
141 | - | os.cancelTimer(xyzTimer) |
141 | + | os.cancelTimer(xyzTimer) |
142 | end | |
143 | - | |
143 | + | |
144 | function launchTimers() | |
145 | - | while true do |
145 | + | while true do |
146 | - | local event, args = os.pullEvent() |
146 | + | local event, args = os.pullEvent() |
147 | - | |
147 | + | |
148 | - | if event == "key" and args == 19 then |
148 | + | if event == "key" and args == 19 then |
149 | - | os.reboot() |
149 | + | os.reboot() |
150 | - | elseif event == "timer" then |
150 | + | elseif event == "timer" then |
151 | - | if args == zyxTimer then |
151 | + | if args == zyxTimer then |
152 | - | rs.setBundledOutput(cfg["redSide"], colors.black) |
152 | + | rs.setBundledOutput(cfg["redSide"], colors.black) |
153 | - | monster010.clearMonitor() |
153 | + | monster010.clearMonitor() |
154 | - | addButtons() |
154 | + | addButtons() |
155 | - | |
155 | + | |
156 | - | os.cancelTimer(zyxTimer) |
156 | + | os.cancelTimer(zyxTimer) |
157 | - | elseif args == xyzTimer then |
157 | + | elseif args == xyzTimer then |
158 | - | closeTor() |
158 | + | closeTor() |
159 | - | elseif args == myTimer then |
159 | + | elseif args == myTimer then |
160 | - | input = "" |
160 | + | input = "" |
161 | - | os.cancelTimer(myTimer) |
161 | + | os.cancelTimer(myTimer) |
162 | - | end |
162 | + | end |
163 | - | end |
163 | + | end |
164 | - | end |
164 | + | end |
165 | end | |
166 | - | |
166 | + | |
167 | config.load("/debipasstor/cfg") | |
168 | cfg = config.getConfig() | |
169 | - | |
169 | + | |
170 | monster010.construct(cfg["monSide"], software) | |
171 | monster010.startUp() | |
172 | monitor = monster010.getMonitor() | |
173 | btn.construct(monitor) | |
174 | - | |
174 | + | |
175 | load() | |
176 | addButtons() | |
177 | - | |
177 | + | |
178 | monster010.startUpDone() | |
179 | - | |
179 | + | |
180 | while true do | |
181 | - | parallel.waitForAny(btn.getClick, launchTimers) |
181 | + | parallel.waitForAny(btn.getClick, launchTimers) |
182 | end |