SHOW:
|
|
- or go back to the newest paste.
1 | --changelog | |
2 | --CURRENT: - v0.3.4 - Security question! | |
3 | --v0.3.3 - updated something | |
4 | --v0.3.2 - Added line 18 - 24, Fixed error of nil, Fixed Lot of thing | |
5 | --v0.3.1 - Fixed serverID | |
6 | --v0.3 - NICKNAME! | |
7 | --v0.2.1 - Fixed serverID | |
8 | --v0.2 - allow to change username & password | |
9 | --v0.1 - Published | |
10 | ||
11 | --Pre-Pre-Alpla version | |
12 | --v0.05 - Fixed some bug | |
13 | --v0.01 - Born | |
14 | ||
15 | - | serverID = --ID HERE |
15 | + | local serverID |
16 | ||
17 | print("serverID is?") | |
18 | term.setCursorPos(1, 2) | |
19 | serverID = read() | |
20 | sleep(1) | |
21 | term.clear() | |
22 | ||
23 | local function enter(username) | |
24 | local nick | |
25 | repeat | |
26 | rednet.send(serverID, "user") | |
27 | sleep(0.5) | |
28 | rednet.send(serverID, username) | |
29 | sleep(0.5) | |
30 | rednet.send(serverID, "check") | |
31 | sleep(0.5) | |
32 | rednet.send(serverID, "could") | |
33 | local ID, MSG, DISTANCE = rednet.receive(10) | |
34 | if MSG == "nope" or MSG == nil or MSG == "" then | |
35 | print("Hello, "..username) | |
36 | elseif MSG == "yes" then | |
37 | local ID, MSG, DISTANCE = rednet.receive(10) | |
38 | nick = MSG | |
39 | print("Hello, "..nick) | |
40 | end | |
41 | print("(1)Edit username") | |
42 | print("(2)Edit password") | |
43 | print("(3)Edit nick") | |
44 | print("(4)Edit Security question") | |
45 | print("(5)Logout") | |
46 | print("1, 2, 3 ,4 or 5?") | |
47 | print(">") | |
48 | term.setCursorPos(2, 8) | |
49 | local num = read() | |
50 | ||
51 | if num == "1" then | |
52 | local nameuser | |
53 | repeat | |
54 | term.setCursorPos(1, 5) | |
55 | print(" ") | |
56 | print(" ") | |
57 | term.setCursorPos(1, 3) | |
58 | print("New username:") | |
59 | print("> ") | |
60 | term.setCursorPos(2, 4) | |
61 | nameuser = read() | |
62 | term.setCursorPos(1, 5) | |
63 | print("Need to change? n for no, y for yes") | |
64 | change = read() | |
65 | until change == "n" | |
66 | term.setCursorPos(1, 5) | |
67 | print(" ") | |
68 | print(" ") | |
69 | term.setCursorPos(1, 5) | |
70 | print("Please wait...") | |
71 | rednet.send(serverID, "user") | |
72 | sleep(0.5) | |
73 | rednet.send(serverID, username) | |
74 | sleep(0.5) | |
75 | rednet.send(serverID, "user2") | |
76 | sleep(0.5) | |
77 | rednet.send(serverID, nameuser) | |
78 | sleep(0.5) | |
79 | rednet.send(serverID, "cn") | |
80 | term.setCursorPos(3, 6) | |
81 | print("Comfirming...") | |
82 | sleep(0.5) | |
83 | rednet.send(serverID, "could") | |
84 | local ID, MSG, DISTANCE = rednet.receive(10) | |
85 | if MSG == "finish" then | |
86 | does = "no" | |
87 | term.setCursorPos(1, 8) | |
88 | print("Please login with your new username.") | |
89 | sleep(3) | |
90 | dooo = "yes" | |
91 | elseif MSG == "nou" then | |
92 | term.setCursorPos(1, 8) | |
93 | print("New username exist.") | |
94 | sleep(2) | |
95 | else | |
96 | term.setCursorPos(1, 8) | |
97 | print("Server closed.") | |
98 | sleep(2) | |
99 | end | |
100 | ||
101 | elseif num == "2" then | |
102 | local password,wordpass | |
103 | repeat | |
104 | term.setCursorPos(1, 7) | |
105 | print(" ") | |
106 | print(" ") | |
107 | term.setCursorPos(1, 3) | |
108 | print("Old password:") | |
109 | print("> ") | |
110 | print("New password:") | |
111 | print("> ") | |
112 | term.setCursorPos(2, 4) | |
113 | password = read("x") | |
114 | term.setCursorPos(2, 6) | |
115 | wordpass = read("x") | |
116 | term.setCursorPos(1, 7) | |
117 | print("Need to change? n for no, y for yes") | |
118 | term.setCursorPos(1, 8) | |
119 | change = read() | |
120 | until change == "n" | |
121 | term.setCursorPos(1, 7) | |
122 | print(" ") | |
123 | print(" ") | |
124 | term.setCursorPos(1, 7) | |
125 | print("Please wait...") | |
126 | rednet.send(serverID, "user") | |
127 | sleep(0.5) | |
128 | rednet.send(serverID, username) | |
129 | sleep(0.5) | |
130 | rednet.send(serverID, "pass") | |
131 | sleep(0.5) | |
132 | rednet.send(serverID, password) | |
133 | sleep(0.5) | |
134 | rednet.send(serverID, "pass2") | |
135 | sleep(0.5) | |
136 | rednet.send(serverID, wordpass) | |
137 | sleep(0.5) | |
138 | rednet.send(serverID, "cp") | |
139 | term.setCursorPos(1, 8) | |
140 | print("Comfirming...") | |
141 | sleep(0.5) | |
142 | rednet.send(serverID, "could") | |
143 | local ID, MSG, DISTANCE = rednet.receive(10) | |
144 | if MSG == "finish" then | |
145 | term.setCursorPos(1, 7) | |
146 | print("Changed password.") | |
147 | print("Please login with your new password.") | |
148 | sleep(3) | |
149 | dooo = "yes" | |
150 | elseif MSG == "wrongp" then | |
151 | term.setCursorPos(1, 7) | |
152 | print("Wrong Old password.") | |
153 | sleep(2) | |
154 | else | |
155 | term.setCursorPos(1, 7) | |
156 | print("Server closed.") | |
157 | sleep(2) | |
158 | end | |
159 | ||
160 | elseif num == "3" then | |
161 | local nick2 | |
162 | repeat | |
163 | term.setCursorPos(1, 5) | |
164 | print(" ") | |
165 | print(" ") | |
166 | term.setCursorPos(1, 3) | |
167 | print("Nickname:") | |
168 | print("> ") | |
169 | term.setCursorPos(2, 4) | |
170 | nick2 = read() | |
171 | term.setCursorPos(1, 5) | |
172 | print("Need to change? n for no, y for yes") | |
173 | term.setCursorPos(1, 6) | |
174 | change = read() | |
175 | until change == "n" | |
176 | term.setCursorPos(1, 5) | |
177 | print(" ") | |
178 | print(" ") | |
179 | term.setCursorPos(1, 5) | |
180 | print("Please wait...") | |
181 | rednet.send(serverID, "user") | |
182 | sleep(0.5) | |
183 | rednet.send(serverID, username) | |
184 | sleep(0.5) | |
185 | rednet.send(serverID, "nick") | |
186 | sleep(0.5) | |
187 | rednet.send(serverID, nick2) | |
188 | sleep(0.5) | |
189 | rednet.send(serverID, "nc") | |
190 | term.setCursorPos(1, 6) | |
191 | print("Comfirming...") | |
192 | sleep(0.5) | |
193 | rednet.send(serverID, "could") | |
194 | local ID, MSG, DISTANCE = rednet.receive(10) | |
195 | if MSG == "finishn" then | |
196 | does = "no" | |
197 | term.setCursorPos(1, 8) | |
198 | print("You have changed your nickname.") | |
199 | sleep(3) | |
200 | elseif MSG == "non" then | |
201 | term.setCursorPos(1, 8) | |
202 | print("New nickname exist.") | |
203 | sleep(2) | |
204 | else | |
205 | term.setCursorPos(1, 7) | |
206 | print("Server closed.") | |
207 | sleep(2) | |
208 | end | |
209 | ||
210 | ||
211 | elseif num == "4" then | |
212 | drawmenu() | |
213 | local question,answer | |
214 | repeat | |
215 | term.setCursorPos(1, 7) | |
216 | print("| |") | |
217 | print("| |") | |
218 | term.setCursorPos(1, 3) | |
219 | print("Security Question:") | |
220 | print("> |") | |
221 | print("Answer:") | |
222 | print("> |") | |
223 | term.setCursorPos(2, 4) | |
224 | question = read() | |
225 | term.setCursorPos(2, 6) | |
226 | answer = read() | |
227 | term.setCursorPos(1, 7) | |
228 | print("Need to change? n for no, y for yes") | |
229 | term.setCursorPos(1, 8) | |
230 | change = read() | |
231 | until change == "n" | |
232 | term.setCursorPos(1, 7) | |
233 | print("| |") | |
234 | print("| |") | |
235 | term.setCursorPos(1, 7) | |
236 | print("Please wait...") | |
237 | rednet.send(serverID, "user") | |
238 | sleep(0.5) | |
239 | rednet.send(serverID, username) | |
240 | sleep(0.5) | |
241 | rednet.send(serverID, "ques") | |
242 | sleep(0.5) | |
243 | rednet.send(serverID, question) | |
244 | sleep(0.5) | |
245 | rednet.send(serverID, "ans") | |
246 | sleep(0.5) | |
247 | rednet.send(serverID, answer) | |
248 | sleep(0.5) | |
249 | rednet.send(serverID, "secur") | |
250 | print("Comfirming...") | |
251 | sleep(0.5) | |
252 | rednet.send(serverID, "could") | |
253 | local ID, MSG, DISTANCE = rednet.receive(10) | |
254 | if MSG == "qdone" then | |
255 | print("Updated Security Question") | |
256 | sleep(3) | |
257 | else | |
258 | print("Server Closed") | |
259 | sleep(2) | |
260 | end | |
261 | ||
262 | ||
263 | elseif num == "5" then | |
264 | drawmenu() | |
265 | term.setCursorPos(3, 3) | |
266 | if nick == nil or nick == "" then | |
267 | print("Bye, "..username) | |
268 | else | |
269 | print("Bye, "..nick) | |
270 | end | |
271 | sleep(2) | |
272 | dooo = "yes" | |
273 | end | |
274 | ||
275 | local function login(rl) | |
276 | local username,password | |
277 | repeat | |
278 | term.setCursorPos(1, 9) | |
279 | print(" ") | |
280 | print(" ") | |
281 | term.setCursorPos(1, 7) | |
282 | print("Username: ") | |
283 | print("Password: ") | |
284 | ||
285 | term.setCursorPos(10, 7) | |
286 | username = read() | |
287 | term.setCursorPos(10, 8) | |
288 | password = read("x") | |
289 | term.setCursorPos(1, 9) | |
290 | print("need to change? y for yes, n for no") | |
291 | term.setCursorPos(1, 10) | |
292 | local change = read() | |
293 | ||
294 | until change == "n" | |
295 | term.setCursorPos(1, 9) | |
296 | print(" ") | |
297 | print(" ") | |
298 | term.setCursorPos(1, 10) | |
299 | print("Please wait while we sending your username..") | |
300 | rednet.send(serverID, "user") | |
301 | sleep(1) | |
302 | print("Done.") | |
303 | rednet.send(serverID, username) | |
304 | sleep(0.5) | |
305 | print("Please wait while we sending your password..") | |
306 | rednet.send(serverID, "pass") | |
307 | sleep(1) | |
308 | print("Done.") | |
309 | rednet.send(serverID, password) | |
310 | sleep(0.5) | |
311 | rednet.send(serverID, rl) | |
312 | sleep(0.5) | |
313 | rednet.send(serverID, "could") | |
314 | term.setCursorPos(3, 14) | |
315 | print("Completed.") | |
316 | ||
317 | local ID, MSG, DISTANCE = rednet.receive(10) | |
318 | if MSG == "complete" then | |
319 | term.setCursorPos(1, 15) | |
320 | print("You have registered.") | |
321 | sleep(3) | |
322 | ||
323 | elseif MSG == "correct" then | |
324 | term.setCursorPos(1, 15) | |
325 | print("You have logged in.") | |
326 | sleep(3) | |
327 | enter(username) | |
328 | ||
329 | elseif MSG == "pass" then | |
330 | term.setCursorPos(1, 15) | |
331 | print("Invalid password.") | |
332 | sleep(3) | |
333 | ||
334 | elseif MSG == "wrong" then | |
335 | term.setCursorPos(1, 15) | |
336 | print("Invalid username.") | |
337 | sleep(3) | |
338 | ||
339 | elseif MSG == "no" then | |
340 | term.setCursorPos(1, 15) | |
341 | print("Username exist.") | |
342 | sleep(3) | |
343 | ||
344 | else | |
345 | term.setCursorPos(1, 15) | |
346 | print("Server closed.") | |
347 | sleep(3) | |
348 | ||
349 | end | |
350 | end | |
351 | ||
352 | term.setCursorPos(1, 1) | |
353 | print("Register or login?(type r/l)") | |
354 | term.setCursorPos(1, 2) | |
355 | rl = read() | |
356 | term.setCursorPos(1, 4) | |
357 | if rl == "r" then | |
358 | print("register:") | |
359 | login(rl) | |
360 | ||
361 | elseif rl == "l" then | |
362 | print("login:") | |
363 | login(rl) | |
364 | ||
365 | else | |
366 | print("what is "..rl.."?") | |
367 | term.setCursorPos(3, 7) | |
368 | print("r for register, l for login") | |
369 | term.setCursorPos(3, 8) | |
370 | print("back to menu") | |
371 | sleep(1) | |
372 | end |