SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | |
2 | -- Root Directories & Extentions -- | |
3 | local Root = ".Network/" | |
4 | local iRoot = ".Network/Info/" | |
5 | ||
6 | --[[ Functions ]]-- | |
7 | -- Misc -- | |
8 | function clear() | |
9 | term.clear() | |
10 | term.setCursorPos(1,1) | |
11 | end | |
12 | ||
13 | function Reset() | |
14 | clear() | |
15 | term.setTextColor(colors.red) | |
16 | write("E-Mail Network") | |
17 | term.setTextColor(colors.yellow) | |
18 | printTR("- Installer -") | |
19 | term.setTextColor(colors.white) | |
20 | printTM("[ Client Edition ]") | |
21 | w, h = term.getSize() | |
22 | print(string.rep("-", w)) write("\n") | |
23 | end | |
24 | ||
25 | function printTR( text ) | |
26 | w, h = term.getSize() | |
27 | term.setCursorPos(w - #text, 1) | |
28 | write(text) | |
29 | end | |
30 | ||
31 | function printTM( text ) | |
32 | local w, h = term.getSize() | |
33 | term.setCursorPos((w - #text) / 2, 1) | |
34 | write(text) | |
35 | end | |
36 | ||
37 | function printC( text ) | |
38 | local x, y = term.getSize() | |
39 | term.setCursorPos(( x - string.len(text)) / 2, y / 2) | |
40 | write( text ) | |
41 | end | |
42 | ||
43 | -- Interface -- | |
44 | Reset() | |
45 | term.setTextColor(colors.yellow) | |
46 | print("Setting Up Directories...") | |
47 | os.sleep(1) | |
48 | fs.makeDir(Root) | |
49 | fs.makeDir(iRoot) | |
50 | print("Getting Needed Files...") | |
51 | Network = --[[ Local Variables ]]-- | |
52 | -- Root Directories & Extentions -- | |
53 | local Root = ".Network/" | |
54 | local iRoot = ".Network/Info/" | |
55 | ||
56 | -- Misc -- | |
57 | local DoNetwork = false | |
58 | local DoNewMsg = false | |
59 | Blacklisted = " key == 14 key == 83 or if key == 144 or if key == 145 or if key == 147 or if key == 181or if key == 13 or if key == 43 or if key == 51 or if key == 52 or if key == 53 or if key == 83 or if key == 144 or if key == 145 or if key == 147 or if key == 181" | |
60 | if fs.exists(iRoot .. "ServerID.txt") then | |
61 | sr = fs.open(iRoot .. "ServerID.txt", "r") | |
62 | ServerID = sr.readLine() sr.close() | |
63 | - | sr = fs.open(iRoot .. "ServerID.txt", "r") |
63 | + | Server = tonumber(ServerID) |
64 | - | ServerID = sr.readLine() sr.close() |
64 | + | IsServer = true |
65 | - | Server = tonumber(ServerID) |
65 | + | |
66 | - | IsServer = true |
66 | + | |
67 | -- Menu Variables -- | |
68 | UseMainMenu = false | |
69 | UseLoginMenu = false | |
70 | UseOptionsMenu = false | |
71 | UseMessagesMenu = false | |
72 | if fs.exists(iRoot .. "LoggedIn.txt") then | |
73 | LoggedIn = true | |
74 | ur = fs.open(iRoot .. "LoggedIn.txt", "r") | |
75 | - | LoggedIn = true |
75 | + | UserLI = ur.readLine() |
76 | - | ur = fs.open(iRoot .. "LoggedIn.txt", "r") |
76 | + | ur.close() |
77 | - | UserLI = ur.readLine() |
77 | + | |
78 | - | ur.close() |
78 | + | LoggedIn = false |
79 | end | |
80 | - | LoggedIn = false |
80 | + | |
81 | --[[ Functions ]]-- | |
82 | -- Misc -- | |
83 | function clear() | |
84 | term.clear() | |
85 | term.setCursorPos(1,1) | |
86 | - | term.clear() |
86 | + | |
87 | - | term.setCursorPos(1,1) |
87 | + | |
88 | function ResetL() | |
89 | clear() | |
90 | term.setTextColor(colors.red) | |
91 | - | clear() |
91 | + | write("E-Mail Network") |
92 | - | term.setTextColor(colors.red) |
92 | + | term.setTextColor(colors.white) |
93 | - | write("E-Mail Network") |
93 | + | w, h = term.getSize() |
94 | - | term.setTextColor(colors.white) |
94 | + | print(string.rep("-", w)) write("\n") |
95 | - | w, h = term.getSize() |
95 | + | |
96 | - | print(string.rep("-", w)) write("\n") |
96 | + | |
97 | function Reset() | |
98 | clear() | |
99 | term.setTextColor(colors.red) | |
100 | - | clear() |
100 | + | write("E-Mail Network") |
101 | - | term.setTextColor(colors.red) |
101 | + | term.setTextColor(colors.yellow) |
102 | - | write("E-Mail Network") |
102 | + | printTR(UserLI) |
103 | - | term.setTextColor(colors.yellow) |
103 | + | term.setTextColor(colors.white) |
104 | - | printTR(UserLI) |
104 | + | w, h = term.getSize() |
105 | - | term.setTextColor(colors.white) |
105 | + | print(string.rep("-", w)) write("\n") |
106 | - | w, h = term.getSize() |
106 | + | |
107 | - | print(string.rep("-", w)) write("\n") |
107 | + | |
108 | function ResetM( text ) | |
109 | clear() | |
110 | term.setTextColor(colors.red) | |
111 | - | clear() |
111 | + | write("E-Mail Network") |
112 | - | term.setTextColor(colors.red) |
112 | + | term.setTextColor(colors.yellow) |
113 | - | write("E-Mail Network") |
113 | + | printTR(UserLI) |
114 | - | term.setTextColor(colors.yellow) |
114 | + | term.setTextColor(colors.white) |
115 | - | printTR(UserLI) |
115 | + | printTM("[ " .. Msg .. " ]") |
116 | - | term.setTextColor(colors.white) |
116 | + | x, y = term.getCursorPos() |
117 | - | printTM("[ " .. Msg .. " ]") |
117 | + | term.setTextColor(colors.orange) |
118 | - | x, y = term.getCursorPos() |
118 | + | printBM(" ( Press DEL To Delete | Press BACKSPACE To Exit ) ") |
119 | - | term.setTextColor(colors.orange) |
119 | + | term.setTextColor(colors.white) |
120 | - | printBM(" ( Press DEL To Delete | Press BACKSPACE To Exit ) ") |
120 | + | term.setCursorPos(x, y) |
121 | - | term.setTextColor(colors.white) |
121 | + | w, h = term.getSize() |
122 | - | term.setCursorPos(x, y) |
122 | + | print(string.rep("-", w)) write("\n") |
123 | - | w, h = term.getSize() |
123 | + | |
124 | - | print(string.rep("-", w)) write("\n") |
124 | + | |
125 | function ResetS( text ) | |
126 | clear() | |
127 | term.setTextColor(colors.red) | |
128 | - | clear() |
128 | + | write("E-Mail Network") |
129 | - | term.setTextColor(colors.red) |
129 | + | term.setTextColor(colors.yellow) |
130 | - | write("E-Mail Network") |
130 | + | printTR(UserLI) |
131 | - | term.setTextColor(colors.yellow) |
131 | + | x, y = term.getCursorPos() |
132 | - | printTR(UserLI) |
132 | + | term.setTextColor(colors.orange) |
133 | - | x, y = term.getCursorPos() |
133 | + | printBM("( Press DELETE To Cancel )") |
134 | - | term.setTextColor(colors.orange) |
134 | + | term.setTextColor(colors.white) |
135 | - | printBM("( Press DELETE To Cancel )") |
135 | + | term.setCursorPos(x, y) |
136 | - | term.setTextColor(colors.white) |
136 | + | w, h = term.getSize() |
137 | - | term.setCursorPos(x, y) |
137 | + | print(string.rep("-", w)) write("\n") |
138 | - | w, h = term.getSize() |
138 | + | |
139 | - | print(string.rep("-", w)) write("\n") |
139 | + | |
140 | function printTR( text ) | |
141 | w, h = term.getSize() | |
142 | term.setCursorPos(w - #text, 1) | |
143 | - | w, h = term.getSize() |
143 | + | write(text) |
144 | - | term.setCursorPos(w - #text, 1) |
144 | + | |
145 | - | write(text) |
145 | + | |
146 | function printTM( text ) | |
147 | local w, h = term.getSize() | |
148 | term.setCursorPos((w - #text) / 2, 1) | |
149 | - | local w, h = term.getSize() |
149 | + | write(text) |
150 | - | term.setCursorPos((w - #text) / 2, 1) |
150 | + | |
151 | - | write(text) |
151 | + | |
152 | function printBM( text ) | |
153 | local w, h = term.getSize() | |
154 | term.setCursorPos((w - #text) / 2, h) | |
155 | - | local w, h = term.getSize() |
155 | + | write(text) |
156 | - | term.setCursorPos((w - #text) / 2, h) |
156 | + | |
157 | - | write(text) |
157 | + | |
158 | function printC( text ) | |
159 | local x, y = term.getSize() | |
160 | term.setCursorPos(( x - string.len(text)) / 2, y / 2) | |
161 | - | local x, y = term.getSize() |
161 | + | write( text ) |
162 | - | term.setCursorPos(( x - string.len(text)) / 2, y / 2) |
162 | + | |
163 | - | write( text ) |
163 | + | |
164 | function Exit() | |
165 | clear() | |
166 | UseMainMenu = false | |
167 | - | clear() |
167 | + | UseLoginMenu = false |
168 | - | UseMainMenu = false |
168 | + | UseMessagesMenu = false |
169 | - | UseLoginMenu = false |
169 | + | DoNetwork = false |
170 | - | UseMessagesMenu = false |
170 | + | |
171 | - | DoNetwork = false |
171 | + | |
172 | -- Menu Function -- | |
173 | function PrintMenu( menu ) | |
174 | for i = 1, #menu do | |
175 | if i == SelectedItem then | |
176 | - | for i = 1, #menu do |
176 | + | if menu[i].MessageName then |
177 | - | if i == SelectedItem then |
177 | + | term.setTextColor(colors.yellow) |
178 | - | if menu[i].MessageName then |
178 | + | print(menu[i].MessageName) |
179 | - | term.setTextColor(colors.yellow) |
179 | + | term.setTextColor(colors.white) |
180 | - | print(menu[i].MessageName) |
180 | + | elseif menu[i].Option then |
181 | - | term.setTextColor(colors.white) |
181 | + | if menu[i].Option == "Reload Inbox" then |
182 | - | elseif menu[i].Option then |
182 | + | term.setTextColor(colors.yellow) |
183 | - | if menu[i].Option == "Reload Inbox" then |
183 | + | print("\n" .. menu[i].Option) |
184 | - | term.setTextColor(colors.yellow) |
184 | + | term.setTextColor(colors.white) |
185 | - | print("\n" .. menu[i].Option) |
185 | + | else |
186 | - | term.setTextColor(colors.white) |
186 | + | term.setTextColor(colors.yellow) |
187 | - | else |
187 | + | print(menu[i].Option) |
188 | - | term.setTextColor(colors.yellow) |
188 | + | term.setTextColor(colors.white) |
189 | - | print(menu[i].Option) |
189 | + | end |
190 | - | term.setTextColor(colors.white) |
190 | + | end |
191 | - | end |
191 | + | else |
192 | - | end |
192 | + | if menu[i].MessageName then |
193 | - | else |
193 | + | term.setTextColor(colors.gray) |
194 | - | if menu[i].MessageName then |
194 | + | print(menu[i].MessageName) |
195 | - | term.setTextColor(colors.gray) |
195 | + | term.setTextColor(colors.white) |
196 | - | print(menu[i].MessageName) |
196 | + | elseif menu[i].Option then |
197 | - | term.setTextColor(colors.white) |
197 | + | if menu[i].Option == "Reload Inbox" then |
198 | - | elseif menu[i].Option then |
198 | + | term.setTextColor(colors.gray) |
199 | - | if menu[i].Option == "Reload Inbox" then |
199 | + | print("\n" .. menu[i].Option) |
200 | - | term.setTextColor(colors.gray) |
200 | + | term.setTextColor(colors.white) |
201 | - | print("\n" .. menu[i].Option) |
201 | + | else |
202 | - | term.setTextColor(colors.white) |
202 | + | term.setTextColor(colors.gray) |
203 | - | else |
203 | + | print(menu[i].Option) |
204 | - | term.setTextColor(colors.gray) |
204 | + | term.setTextColor(colors.white) |
205 | - | print(menu[i].Option) |
205 | + | end |
206 | - | term.setTextColor(colors.white) |
206 | + | end |
207 | - | end |
207 | + | end |
208 | - | end |
208 | + | end |
209 | - | end |
209 | + | |
210 | - | end |
210 | + | |
211 | function KeyHandler( key, menu ) | |
212 | if key == 28 then | |
213 | UseOption(menu) | |
214 | - | if key == 28 then |
214 | + | elseif key == 200 then |
215 | - | UseOption(menu) |
215 | + | if SelectedItem > 1 then |
216 | - | elseif key == 200 then |
216 | + | SelectedItem = SelectedItem - 1 |
217 | - | if SelectedItem > 1 then |
217 | + | else |
218 | - | SelectedItem = SelectedItem - 1 |
218 | + | SelectedItem = #menu |
219 | - | else |
219 | + | end |
220 | - | SelectedItem = #menu |
220 | + | elseif key == 208 then |
221 | - | end |
221 | + | if SelectedItem < #menu then |
222 | - | elseif key == 208 then |
222 | + | SelectedItem = SelectedItem + 1 |
223 | - | if SelectedItem < #menu then |
223 | + | else |
224 | - | SelectedItem = SelectedItem + 1 |
224 | + | SelectedItem = 1 |
225 | - | else |
225 | + | end |
226 | - | SelectedItem = 1 |
226 | + | end |
227 | - | end |
227 | + | |
228 | - | end |
228 | + | |
229 | function UseOption( menu ) | |
230 | if menu[SelectedItem].MessageName then | |
231 | Msg = menu[SelectedItem].MessageName | |
232 | - | if menu[SelectedItem].MessageName then |
232 | + | RUser = Messages[SelectedItem].RUser |
233 | - | Msg = menu[SelectedItem].MessageName |
233 | + | ResetM(Msg) |
234 | - | RUser = Messages[SelectedItem].RUser |
234 | + | term.setTextColor(colors.yellow) |
235 | - | ResetM(Msg) |
235 | + | write("From: ") term.setTextColor(colors.white) write(menu[SelectedItem].Sender) term.setTextColor(colors.yellow) write("\nMessage:") term.setTextColor(colors.white) write("\n\n" .. menu[SelectedItem].Message) |
236 | - | term.setTextColor(colors.yellow) |
236 | + | repeat |
237 | - | write("From: ") term.setTextColor(colors.white) write(menu[SelectedItem].Sender) term.setTextColor(colors.yellow) write("\nMessage:") term.setTextColor(colors.white) write("\n\n" .. menu[SelectedItem].Message) |
237 | + | event, key = os.pullEvent("key") |
238 | - | repeat |
238 | + | os.sleep(0.1) |
239 | - | event, key = os.pullEvent("key") |
239 | + | until key == 14 or key == 211 |
240 | - | os.sleep(0.1) |
240 | + | if key == 211 then |
241 | - | until key == 14 or key == 211 |
241 | + | rednet.send(Server, "DeleteMessage") |
242 | - | if key == 211 then |
242 | + | os.sleep(0.1) |
243 | - | rednet.send(Server, "DeleteMessage") |
243 | + | rednet.send(Server, Msg) |
244 | - | os.sleep(0.1) |
244 | + | os.sleep(0.1) |
245 | - | rednet.send(Server, Msg) |
245 | + | rednet.send(Server, RUser) |
246 | - | os.sleep(0.1) |
246 | + | os.sleep(0.1) |
247 | - | rednet.send(Server, RUser) |
247 | + | Inbox() |
248 | - | os.sleep(0.1) |
248 | + | elseif key == 14 then |
249 | - | Inbox() |
249 | + | Inbox() |
250 | - | elseif key == 14 then |
250 | + | end |
251 | - | Inbox() |
251 | + | elseif menu[SelectedItem].Function then |
252 | - | end |
252 | + | menu[SelectedItem].Function() |
253 | - | elseif menu[SelectedItem].Function then |
253 | + | elseif menu[SelectedItem].Option == "Back" then |
254 | - | menu[SelectedItem].Function() |
254 | + | Back() |
255 | - | elseif menu[SelectedItem].Option == "Back" then |
255 | + | elseif menu[SelectedItem].Option == "Reload Inbox" then |
256 | - | Back() |
256 | + | Inbox() |
257 | - | elseif menu[SelectedItem].Option == "Reload Inbox" then |
257 | + | elseif menu[SelectedItem].File then |
258 | - | Inbox() |
258 | + | Exit() |
259 | - | elseif menu[SelectedItem].File then |
259 | + | shell.run(menu[SelectedItem].File) |
260 | - | Exit() |
260 | + | else |
261 | - | shell.run(menu[SelectedItem].File) |
261 | + | clear() |
262 | - | else |
262 | + | term.setTextColor(colors.red) |
263 | - | clear() |
263 | + | printC("There Was An Error!") |
264 | - | term.setTextColor(colors.red) |
264 | + | term.setTextColor(colors.white) |
265 | - | printC("There Was An Error!") |
265 | + | os.sleep(2) |
266 | - | term.setTextColor(colors.white) |
266 | + | clear() |
267 | - | os.sleep(2) |
267 | + | printC("Restarting Computer") |
268 | - | clear() |
268 | + | os.sleep(2) |
269 | - | printC("Restarting Computer") |
269 | + | os.reboot() |
270 | - | os.sleep(2) |
270 | + | end |
271 | - | os.reboot() |
271 | + | |
272 | - | end |
272 | + | |
273 | -- Handler Function -- | |
274 | function Back() | |
275 | term.setCursorBlink(false) | |
276 | os.reboot() | |
277 | - | term.setCursorBlink(false) |
277 | + | |
278 | - | os.reboot() |
278 | + | |
279 | function FormInbox() | |
280 | if Messages then | |
281 | table.remove(Messages) | |
282 | - | if Messages then |
282 | + | end |
283 | - | table.remove(Messages) |
283 | + | Reset() |
284 | - | end |
284 | + | print("Loading Inbox...") |
285 | - | Reset() |
285 | + | rednet.send(Server, "RetrieveMessage") |
286 | - | print("Loading Inbox...") |
286 | + | os.sleep(0.1) |
287 | - | rednet.send(Server, "RetrieveMessage") |
287 | + | ur = fs.open(iRoot .. "LoggedIn.txt", "r") |
288 | - | os.sleep(0.1) |
288 | + | Username = ur.readLine() |
289 | - | ur = fs.open(iRoot .. "LoggedIn.txt", "r") |
289 | + | ur.close() |
290 | - | Username = ur.readLine() |
290 | + | rednet.send(Server, Username) |
291 | - | ur.close() |
291 | + | ID, MessageInfo = rednet.receive(5) |
292 | - | rednet.send(Server, Username) |
292 | + | if MessageInfo then |
293 | - | ID, MessageInfo = rednet.receive(5) |
293 | + | Messages = textutils.unserialize(MessageInfo) |
294 | - | if MessageInfo then |
294 | + | else |
295 | - | Messages = textutils.unserialize(MessageInfo) |
295 | + | Reset() |
296 | - | else |
296 | + | term.setTextColor(colors.red) |
297 | - | Reset() |
297 | + | print("Inbox Failed To Load!\nMake Sure That The E-Mail Server Is On!") |
298 | - | term.setTextColor(colors.red) |
298 | + | term.setTextColor(colors.yellow) |
299 | - | print("Inbox Failed To Load!\nMake Sure That The E-Mail Server Is On!") |
299 | + | print("\n(-)Ok") |
300 | - | term.setTextColor(colors.yellow) |
300 | + | term.setTextColor(colors.white) |
301 | - | print("\n(-)Ok") |
301 | + | repeat |
302 | - | term.setTextColor(colors.white) |
302 | + | event, key = os.pullEvent("key") |
303 | - | repeat |
303 | + | os.sleep(0.1) |
304 | - | event, key = os.pullEvent("key") |
304 | + | until key == 28 |
305 | - | os.sleep(0.1) |
305 | + | Back() |
306 | - | until key == 28 |
306 | + | end |
307 | - | Back() |
307 | + | |
308 | - | end |
308 | + | |
309 | function LogIn() | |
310 | ResetL() | |
311 | if IsServer then | |
312 | - | ResetL() |
312 | + | print("Log In\n") |
313 | - | if IsServer then |
313 | + | term.setTextColor(colors.yellow) |
314 | - | print("Log In\n") |
314 | + | write("Username: ") |
315 | - | term.setTextColor(colors.yellow) |
315 | + | x, y = term.getCursorPos() |
316 | - | write("Username: ") |
316 | + | write("\nPassword: ") |
317 | - | x, y = term.getCursorPos() |
317 | + | term.setTextColor(colors.white) |
318 | - | write("\nPassword: ") |
318 | + | x2, y2 = term.getCursorPos() |
319 | - | term.setTextColor(colors.white) |
319 | + | term.setCursorPos(x, y) |
320 | - | x2, y2 = term.getCursorPos() |
320 | + | Username = read() |
321 | - | term.setCursorPos(x, y) |
321 | + | term.setCursorPos(x2, y2) |
322 | - | Username = read() |
322 | + | Password = read("*") |
323 | - | term.setCursorPos(x2, y2) |
323 | + | print("\nVerifying Information...") |
324 | - | Password = read("*") |
324 | + | rednet.send(Server, "VerifyUser") |
325 | - | print("\nVerifying Information...") |
325 | + | os.sleep(0.1) |
326 | - | rednet.send(Server, "VerifyUser") |
326 | + | rednet.send(Server, Username) |
327 | - | os.sleep(0.1) |
327 | + | os.sleep(0.1) |
328 | - | rednet.send(Server, Username) |
328 | + | rednet.send(Server, Password) |
329 | - | os.sleep(0.1) |
329 | + | ID, Success = rednet.receive(5) |
330 | - | rednet.send(Server, Password) |
330 | + | if Success then |
331 | - | ID, Success = rednet.receive(5) |
331 | + | if Success == "true" then |
332 | - | if Success then |
332 | + | uw = fs.open(iRoot .. "LoggedIn.txt", "w") |
333 | - | if Success == "true" then |
333 | + | uw.writeLine(Username) |
334 | - | uw = fs.open(iRoot .. "LoggedIn.txt", "w") |
334 | + | uw.close() |
335 | - | uw.writeLine(Username) |
335 | + | term.setTextColor(colors.lime) |
336 | - | uw.close() |
336 | + | print("\nYou Have Been Logged In Successfully!") |
337 | - | term.setTextColor(colors.lime) |
337 | + | term.setTextColor(colors.yellow) |
338 | - | print("\nYou Have Been Logged In Successfully!") |
338 | + | print("\n(-)Ok") |
339 | - | term.setTextColor(colors.yellow) |
339 | + | term.setTextColor(colors.white) |
340 | - | print("\n(-)Ok") |
340 | + | repeat |
341 | - | term.setTextColor(colors.white) |
341 | + | event, key = os.pullEvent("key") |
342 | - | repeat |
342 | + | os.sleep(0.1) |
343 | - | event, key = os.pullEvent("key") |
343 | + | until key == 28 |
344 | - | os.sleep(0.1) |
344 | + | LoggedIn = true |
345 | - | until key == 28 |
345 | + | UserLI = Username |
346 | - | LoggedIn = true |
346 | + | Back() |
347 | - | UserLI = Username |
347 | + | else |
348 | - | Back() |
348 | + | term.setTextColor(colors.red) |
349 | - | else |
349 | + | print("\nIncorrect Username / Password!") |
350 | - | term.setTextColor(colors.red) |
350 | + | term.setTextColor(colors.yellow) |
351 | - | print("\nIncorrect Username / Password!") |
351 | + | print("\n(-)Ok") |
352 | - | term.setTextColor(colors.yellow) |
352 | + | repeat |
353 | - | print("\n(-)Ok") |
353 | + | event, key = os.pullEvent("key") |
354 | - | repeat |
354 | + | os.sleep(0.1) |
355 | - | event, key = os.pullEvent("key") |
355 | + | until key == 28 |
356 | - | os.sleep(0.1) |
356 | + | Back() |
357 | - | until key == 28 |
357 | + | end |
358 | - | Back() |
358 | + | else |
359 | - | end |
359 | + | term.setTextColor(colors.red) |
360 | - | else |
360 | + | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
361 | - | term.setTextColor(colors.red) |
361 | + | term.setTextColor(colors.yellow) |
362 | - | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
362 | + | print("\n(-)Ok") |
363 | - | term.setTextColor(colors.yellow) |
363 | + | term.setTextColor(colors.white) |
364 | - | print("\n(-)Ok") |
364 | + | repeat |
365 | - | term.setTextColor(colors.white) |
365 | + | event, key = os.pullEvent("key") |
366 | - | repeat |
366 | + | os.sleep(0.1) |
367 | - | event, key = os.pullEvent("key") |
367 | + | until key == 28 |
368 | - | os.sleep(0.1) |
368 | + | Back() |
369 | - | until key == 28 |
369 | + | end |
370 | - | Back() |
370 | + | else |
371 | - | end |
371 | + | ResetL() |
372 | - | else |
372 | + | print("Log In\n") |
373 | - | ResetL() |
373 | + | term.setTextColor(colors.red) |
374 | - | print("Log In\n") |
374 | + | print("You Have Not Set Up The Information For Rednet! \nYou Must Set Up The Information In Options Before Logging In!") |
375 | - | term.setTextColor(colors.red) |
375 | + | term.setTextColor(colors.yellow) |
376 | - | print("You Have Not Set Up The Information For Rednet! \nYou Must Set Up The Information In Options Before Logging In!") |
376 | + | print("\n(-)Ok") |
377 | - | term.setTextColor(colors.yellow) |
377 | + | term.setTextColor(colors.white) |
378 | - | print("\n(-)Ok") |
378 | + | repeat |
379 | - | term.setTextColor(colors.white) |
379 | + | event, key = os.pullEvent("key") |
380 | - | repeat |
380 | + | os.sleep(0.1) |
381 | - | event, key = os.pullEvent("key") |
381 | + | until key == 28 |
382 | - | os.sleep(0.1) |
382 | + | Back() |
383 | - | until key == 28 |
383 | + | end |
384 | - | Back() |
384 | + | |
385 | - | end |
385 | + | |
386 | function Reboot() | |
387 | ResetL() | |
388 | textutils.slowPrint("Rebooting Computer...") | |
389 | - | ResetL() |
389 | + | os.sleep(1) |
390 | - | textutils.slowPrint("Rebooting Computer...") |
390 | + | os.reboot() |
391 | - | os.sleep(1) |
391 | + | |
392 | - | os.reboot() |
392 | + | |
393 | function Shutdown() | |
394 | ResetL() | |
395 | textutils.slowPrint("Shutting Down Computer...") | |
396 | - | ResetL() |
396 | + | os.sleep(1) |
397 | - | textutils.slowPrint("Shutting Down Computer...") |
397 | + | os.shutdown() |
398 | - | os.sleep(1) |
398 | + | |
399 | - | os.shutdown() |
399 | + | |
400 | function SendMessage() | |
401 | ResetS() | |
402 | print("Compose Message\n") | |
403 | - | ResetS() |
403 | + | term.setTextColor(colors.yellow) |
404 | - | print("Compose Message\n") |
404 | + | write("To (Enter Username): ") |
405 | - | term.setTextColor(colors.yellow) |
405 | + | x, y = term.getCursorPos() |
406 | - | write("To (Enter Username): ") |
406 | + | write("\nSubject: ") |
407 | - | x, y = term.getCursorPos() |
407 | + | x2, y2 = term.getCursorPos() |
408 | - | write("\nSubject: ") |
408 | + | write("\nMessage: ") |
409 | - | x2, y2 = term.getCursorPos() |
409 | + | term.setTextColor(colors.white) |
410 | - | write("\nMessage: ") |
410 | + | x3, y3 = term.getCursorPos() |
411 | - | term.setTextColor(colors.white) |
411 | + | term.setCursorPos(x, y) |
412 | - | x3, y3 = term.getCursorPos() |
412 | + | Username = "" |
413 | - | term.setCursorPos(x, y) |
413 | + | UsernameLength = 20 |
414 | - | Username = "" |
414 | + | while true do |
415 | - | UsernameLength = 20 |
415 | + | printTM(" [ " .. #Username .. "/" .. UsernameLength .. " ] ") |
416 | - | while true do |
416 | + | term.setCursorPos(x, y) |
417 | - | printTM(" [ " .. #Username .. "/" .. UsernameLength .. " ] ") |
417 | + | term.setCursorBlink(true) |
418 | - | term.setCursorPos(x, y) |
418 | + | write(Username) |
419 | - | term.setCursorBlink(true) |
419 | + | |
420 | - | write(Username) |
420 | + | local event, key = os.pullEvent() |
421 | - | |
421 | + | if event == "char" then |
422 | - | local event, key = os.pullEvent() |
422 | + | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
423 | - | if event == "char" then |
423 | + | Username = Username .. "" |
424 | - | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
424 | + | elseif key == " " then |
425 | - | Username = Username .. "" |
425 | + | Username = Username .. "_" |
426 | - | elseif key == " " then |
426 | + | else |
427 | - | Username = Username .. "_" |
427 | + | if #Username < UsernameLength then |
428 | - | else |
428 | + | Username = Username .. key |
429 | - | if #Username < UsernameLength then |
429 | + | else |
430 | - | Username = Username .. key |
430 | + | Username = Username .. "" |
431 | - | else |
431 | + | end |
432 | - | Username = Username .. "" |
432 | + | end |
433 | - | end |
433 | + | elseif event == "key" then |
434 | - | end |
434 | + | if key == 14 then |
435 | - | elseif event == "key" then |
435 | + | Username = Username:sub(1, #Username - 1) |
436 | - | if key == 14 then |
436 | + | w, h = term.getCursorPos() |
437 | - | Username = Username:sub(1, #Username - 1) |
437 | + | term.setCursorPos(w - 1, h) |
438 | - | w, h = term.getCursorPos() |
438 | + | write(" ") |
439 | - | term.setCursorPos(w - 1, h) |
439 | + | term.setCursorPos(w, h) |
440 | - | write(" ") |
440 | + | elseif key == 211 then |
441 | - | term.setCursorPos(w, h) |
441 | + | Back() |
442 | - | elseif key == 211 then |
442 | + | elseif key == 28 then |
443 | - | Back() |
443 | + | break |
444 | - | elseif key == 28 then |
444 | + | end |
445 | - | break |
445 | + | end |
446 | - | end |
446 | + | end |
447 | - | end |
447 | + | term.setCursorPos(x2, y2) |
448 | - | end |
448 | + | MessageName = "" |
449 | - | term.setCursorPos(x2, y2) |
449 | + | MessageNameLength = 14 |
450 | - | MessageName = "" |
450 | + | while true do |
451 | - | MessageNameLength = 14 |
451 | + | printTM(" [ " .. #MessageName .. "/" .. MessageNameLength .. " ] ") |
452 | - | while true do |
452 | + | term.setCursorPos(x2, y2) |
453 | - | printTM(" [ " .. #MessageName .. "/" .. MessageNameLength .. " ] ") |
453 | + | term.setCursorBlink(true) |
454 | - | term.setCursorPos(x2, y2) |
454 | + | write(MessageName) |
455 | - | term.setCursorBlink(true) |
455 | + | |
456 | - | write(MessageName) |
456 | + | local event, key = os.pullEvent() |
457 | - | |
457 | + | if event == "char" then |
458 | - | local event, key = os.pullEvent() |
458 | + | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
459 | - | if event == "char" then |
459 | + | MessageName = MessageName .. "" |
460 | - | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
460 | + | elseif key == " " then |
461 | - | MessageName = MessageName .. "" |
461 | + | MessageName = MessageName .. "_" |
462 | - | elseif key == " " then |
462 | + | else |
463 | - | MessageName = MessageName .. "_" |
463 | + | if #MessageName < MessageNameLength then |
464 | - | else |
464 | + | MessageName = MessageName .. key |
465 | - | if #MessageName < MessageNameLength then |
465 | + | else |
466 | - | MessageName = MessageName .. key |
466 | + | MessageName = MessageName .. "" |
467 | - | else |
467 | + | end |
468 | - | MessageName = MessageName .. "" |
468 | + | end |
469 | - | end |
469 | + | elseif event == "key" then |
470 | - | end |
470 | + | if key == 14 then |
471 | - | elseif event == "key" then |
471 | + | MessageName = MessageName:sub(1, #MessageName - 1) |
472 | - | if key == 14 then |
472 | + | w, h = term.getCursorPos() |
473 | - | MessageName = MessageName:sub(1, #MessageName - 1) |
473 | + | term.setCursorPos(w - 1, h) |
474 | - | w, h = term.getCursorPos() |
474 | + | write(" ") |
475 | - | term.setCursorPos(w - 1, h) |
475 | + | term.setCursorPos(w, h) |
476 | - | write(" ") |
476 | + | elseif key == 211 then |
477 | - | term.setCursorPos(w, h) |
477 | + | Back() |
478 | - | elseif key == 211 then |
478 | + | elseif key == 28 then |
479 | - | Back() |
479 | + | break |
480 | - | elseif key == 28 then |
480 | + | end |
481 | - | break |
481 | + | end |
482 | - | end |
482 | + | end |
483 | - | end |
483 | + | Message = "" |
484 | - | end |
484 | + | MessageLength = 400 |
485 | - | Message = "" |
485 | + | while true do |
486 | - | MessageLength = 400 |
486 | + | printTM(" [ " .. #Message .. "/" .. MessageLength .. " ] ") |
487 | - | while true do |
487 | + | term.setCursorPos(x3, y3) |
488 | - | printTM(" [ " .. #Message .. "/" .. MessageLength .. " ] ") |
488 | + | term.setCursorBlink(true) |
489 | - | term.setCursorPos(x3, y3) |
489 | + | write(Message) |
490 | - | term.setCursorBlink(true) |
490 | + | |
491 | - | write(Message) |
491 | + | local event, key = os.pullEvent() |
492 | - | |
492 | + | if event == "char" then |
493 | - | local event, key = os.pullEvent() |
493 | + | if #Message < MessageLength then |
494 | - | if event == "char" then |
494 | + | Message = Message .. key |
495 | - | if #Message < MessageLength then |
495 | + | else |
496 | - | Message = Message .. key |
496 | + | Message = Message .. "" |
497 | - | else |
497 | + | end |
498 | - | Message = Message .. "" |
498 | + | elseif event == "key" then |
499 | - | end |
499 | + | if key == 14 then |
500 | - | elseif event == "key" then |
500 | + | Message = Message:sub(1, #Message - 1) |
501 | - | if key == 14 then |
501 | + | w, h = term.getCursorPos() |
502 | - | Message = Message:sub(1, #Message - 1) |
502 | + | term.setCursorPos(w - 1, h) |
503 | - | w, h = term.getCursorPos() |
503 | + | write(" ") |
504 | - | term.setCursorPos(w - 1, h) |
504 | + | term.setCursorPos(w, h) |
505 | - | write(" ") |
505 | + | elseif key == 211 then |
506 | - | term.setCursorPos(w, h) |
506 | + | Back() |
507 | - | elseif key == 211 then |
507 | + | elseif key == 28 then |
508 | - | Back() |
508 | + | break |
509 | - | elseif key == 28 then |
509 | + | end |
510 | - | break |
510 | + | end |
511 | - | end |
511 | + | end |
512 | - | end |
512 | + | term.setCursorBlink(false) |
513 | - | end |
513 | + | Reset() |
514 | - | term.setCursorBlink(false) |
514 | + | textutils.slowWrite("Sending ") term.setTextColor(colors.yellow) textutils.slowWrite(Username) term.setTextColor(colors.white) textutils.slowWrite("'s Message...") |
515 | - | Reset() |
515 | + | cr = fs.open(iRoot .. "LoggedIn.txt", "r") |
516 | - | textutils.slowWrite("Sending ") term.setTextColor(colors.yellow) textutils.slowWrite(Username) term.setTextColor(colors.white) textutils.slowWrite("'s Message...") |
516 | + | Sender = cr.readLine() |
517 | - | cr = fs.open(iRoot .. "LoggedIn.txt", "r") |
517 | + | cr.close() |
518 | - | Sender = cr.readLine() |
518 | + | rednet.send(Server, "SendMessage") |
519 | - | cr.close() |
519 | + | os.sleep(0.1) |
520 | - | rednet.send(Server, "SendMessage") |
520 | + | rednet.send(Server, Username) |
521 | - | os.sleep(0.1) |
521 | + | os.sleep(0.1) |
522 | - | rednet.send(Server, Username) |
522 | + | rednet.send(Server, Sender) |
523 | - | os.sleep(0.1) |
523 | + | os.sleep(0.1) |
524 | - | rednet.send(Server, Sender) |
524 | + | rednet.send(Server, MessageName) |
525 | - | os.sleep(0.1) |
525 | + | os.sleep(0.1) |
526 | - | rednet.send(Server, MessageName) |
526 | + | rednet.send(Server, Message) |
527 | - | os.sleep(0.1) |
527 | + | ID, Success = rednet.receive(5) |
528 | - | rednet.send(Server, Message) |
528 | + | if Success then |
529 | - | ID, Success = rednet.receive(5) |
529 | + | if Success == "true" then |
530 | - | if Success then |
530 | + | Reset() |
531 | - | if Success == "true" then |
531 | + | term.setTextColor(colors.lime) |
532 | - | Reset() |
532 | + | print("Message Has Been Sent!") |
533 | - | term.setTextColor(colors.lime) |
533 | + | term.setTextColor(colors.yellow) |
534 | - | print("Message Has Been Sent!") |
534 | + | print("\n(-)Ok") |
535 | - | term.setTextColor(colors.yellow) |
535 | + | term.setTextColor(colors.white) |
536 | - | print("\n(-)Ok") |
536 | + | repeat |
537 | - | term.setTextColor(colors.white) |
537 | + | event, key = os.pullEvent("key") |
538 | - | repeat |
538 | + | os.sleep(0.1) |
539 | - | event, key = os.pullEvent("key") |
539 | + | until key == 28 |
540 | - | os.sleep(0.1) |
540 | + | Back() |
541 | - | until key == 28 |
541 | + | elseif Success == "false" then |
542 | - | Back() |
542 | + | Reset() |
543 | - | elseif Success == "false" then |
543 | + | term.setTextColor(colors.red) |
544 | - | Reset() |
544 | + | print("Message Failed To Send!") |
545 | - | term.setTextColor(colors.red) |
545 | + | print("Make Sure The User Exists And That You Typed A Subject And A Message!") |
546 | - | print("Message Failed To Send!") |
546 | + | term.setTextColor(colors.yellow) |
547 | - | print("Make Sure The User Exists And That You Typed A Subject And A Message!") |
547 | + | print("\n(-)Ok") |
548 | - | term.setTextColor(colors.yellow) |
548 | + | term.setTextColor(colors.white) |
549 | - | print("\n(-)Ok") |
549 | + | repeat |
550 | - | term.setTextColor(colors.white) |
550 | + | event, key = os.pullEvent("key") |
551 | - | repeat |
551 | + | os.sleep(0.1) |
552 | - | event, key = os.pullEvent("key") |
552 | + | until key == 28 |
553 | - | os.sleep(0.1) |
553 | + | Back() |
554 | - | until key == 28 |
554 | + | end |
555 | - | Back() |
555 | + | else |
556 | - | end |
556 | + | term.setTextColor(colors.red) |
557 | - | else |
557 | + | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
558 | - | term.setTextColor(colors.red) |
558 | + | term.setTextColor(colors.yellow) |
559 | - | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
559 | + | print("\n(-)Ok") |
560 | - | term.setTextColor(colors.yellow) |
560 | + | term.setTextColor(colors.white) |
561 | - | print("\n(-)Ok") |
561 | + | repeat |
562 | - | term.setTextColor(colors.white) |
562 | + | event, key = os.pullEvent("key") |
563 | - | repeat |
563 | + | os.sleep(0.1) |
564 | - | event, key = os.pullEvent("key") |
564 | + | until key == 28 |
565 | - | os.sleep(0.1) |
565 | + | Back() |
566 | - | until key == 28 |
566 | + | end |
567 | - | Back() |
567 | + | |
568 | - | end |
568 | + | |
569 | function Inbox() | |
570 | FormInbox() | |
571 | SelectedItem = 1 | |
572 | - | FormInbox() |
572 | + | UseMessagesMenu = true UseMainMenu = false |
573 | - | SelectedItem = 1 |
573 | + | while UseMessagesMenu do |
574 | - | UseMessagesMenu = true UseMainMenu = false |
574 | + | Reset() |
575 | - | while UseMessagesMenu do |
575 | + | print("Your Inbox\n") |
576 | - | Reset() |
576 | + | PrintMenu(Messages) |
577 | - | print("Your Inbox\n") |
577 | + | |
578 | - | PrintMenu(Messages) |
578 | + | event, key = os.pullEvent("key") |
579 | - | |
579 | + | KeyHandler(key, Messages) |
580 | - | event, key = os.pullEvent("key") |
580 | + | end |
581 | - | KeyHandler(key, Messages) |
581 | + | |
582 | - | end |
582 | + | |
583 | function LogOut() | |
584 | ResetL() | |
585 | textutils.slowPrint("Logging Out...") | |
586 | - | ResetL() |
586 | + | os.sleep(1) |
587 | - | textutils.slowPrint("Logging Out...") |
587 | + | fs.delete(iRoot .. "LoggedIn.txt") |
588 | - | os.sleep(1) |
588 | + | os.reboot() |
589 | - | fs.delete(iRoot .. "LoggedIn.txt") |
589 | + | |
590 | - | os.reboot() |
590 | + | |
591 | function SetID() | |
592 | ResetL() | |
593 | print("Set E-Mail Server's Computer ID\n") | |
594 | - | ResetL() |
594 | + | term.setTextColor(colors.yellow) |
595 | - | print("Set E-Mail Server's Computer ID\n") |
595 | + | write("Computer ID: ") |
596 | - | term.setTextColor(colors.yellow) |
596 | + | term.setTextColor(colors.white) |
597 | - | write("Computer ID: ") |
597 | + | ComputerID = read() |
598 | - | term.setTextColor(colors.white) |
598 | + | cw = fs.open(iRoot .. "ServerID.txt", "w") |
599 | - | ComputerID = read() |
599 | + | cw.write(ComputerID) |
600 | - | cw = fs.open(iRoot .. "ServerID.txt", "w") |
600 | + | cw.close() |
601 | - | cw.write(ComputerID) |
601 | + | Server = ComputerID |
602 | - | cw.close() |
602 | + | term.setTextColor(colors.lime) |
603 | - | Server = ComputerID |
603 | + | print("\nE-Mail Server ID Has Been Set!") |
604 | - | term.setTextColor(colors.lime) |
604 | + | term.setTextColor(colors.yellow) |
605 | - | print("\nE-Mail Server ID Has Been Set!") |
605 | + | print("\n(-)Ok") |
606 | - | term.setTextColor(colors.yellow) |
606 | + | term.setTextColor(colors.white) |
607 | - | print("\n(-)Ok") |
607 | + | repeat |
608 | - | term.setTextColor(colors.white) |
608 | + | event, key = os.pullEvent("key") |
609 | - | repeat |
609 | + | os.sleep(0.1) |
610 | - | event, key = os.pullEvent("key") |
610 | + | until key == 28 |
611 | - | os.sleep(0.1) |
611 | + | os.reboot() |
612 | - | until key == 28 |
612 | + | |
613 | - | os.reboot() |
613 | + | |
614 | function NewUser() | |
615 | ResetL() | |
616 | print("New User Account\n") | |
617 | - | ResetL() |
617 | + | term.setTextColor(colors.yellow) |
618 | - | print("New User Account\n") |
618 | + | write("Enter A Username: ") |
619 | - | term.setTextColor(colors.yellow) |
619 | + | term.setTextColor(colors.white) |
620 | - | write("Enter A Username: ") |
620 | + | x, y = term.getCursorPos() |
621 | - | term.setTextColor(colors.white) |
621 | + | Username = "" |
622 | - | x, y = term.getCursorPos() |
622 | + | while true do |
623 | - | Username = "" |
623 | + | printTM(" [ " .. #Username .. "/20 ] ") |
624 | - | while true do |
624 | + | term.setCursorPos(x, y) |
625 | - | printTM(" [ " .. #Username .. "/20 ] ") |
625 | + | term.setCursorBlink(true) |
626 | - | term.setCursorPos(x, y) |
626 | + | write(Username) |
627 | - | term.setCursorBlink(true) |
627 | + | |
628 | - | write(Username) |
628 | + | local event, key = os.pullEvent() |
629 | - | |
629 | + | if event == "char" then |
630 | - | local event, key = os.pullEvent() |
630 | + | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
631 | - | if event == "char" then |
631 | + | Username = Username .. "" |
632 | - | if key == "," or key == "." or key == "/" or key == "\\" or key == ":" or key == "*" or key == "?" or key == "\"" or key == "<" or key == ">" or key == "|" then |
632 | + | elseif key == " " then |
633 | - | Username = Username .. "" |
633 | + | Username = Username .. "_" |
634 | - | elseif key == " " then |
634 | + | else |
635 | - | Username = Username .. "_" |
635 | + | if #Username < 20 then |
636 | - | else |
636 | + | Username = Username .. key |
637 | - | if #Username < 20 then |
637 | + | else |
638 | - | Username = Username .. key |
638 | + | Username = Username .. "" |
639 | - | else |
639 | + | end |
640 | - | Username = Username .. "" |
640 | + | end |
641 | - | end |
641 | + | elseif event == "key" then |
642 | - | end |
642 | + | if key == 14 then |
643 | - | elseif event == "key" then |
643 | + | Username = Username:sub(1, #Username - 1) |
644 | - | if key == 14 then |
644 | + | w, h = term.getCursorPos() |
645 | - | Username = Username:sub(1, #Username - 1) |
645 | + | term.setCursorPos(w - 1, h) |
646 | - | w, h = term.getCursorPos() |
646 | + | write(" ") |
647 | - | term.setCursorPos(w - 1, h) |
647 | + | term.setCursorPos(w, h) |
648 | - | write(" ") |
648 | + | elseif key == 211 then |
649 | - | term.setCursorPos(w, h) |
649 | + | Back() |
650 | - | elseif key == 211 then |
650 | + | elseif key == 28 then |
651 | - | Back() |
651 | + | break |
652 | - | elseif key == 28 then |
652 | + | end |
653 | - | break |
653 | + | end |
654 | - | end |
654 | + | end |
655 | - | end |
655 | + | repeat |
656 | - | end |
656 | + | term.setTextColor(colors.yellow) |
657 | - | repeat |
657 | + | write("\n\nEnter A Password: ") |
658 | - | term.setTextColor(colors.yellow) |
658 | + | term.setTextColor(colors.white) |
659 | - | write("\n\nEnter A Password: ") |
659 | + | Password = read("*") |
660 | - | term.setTextColor(colors.white) |
660 | + | term.setTextColor(colors.yellow) |
661 | - | Password = read("*") |
661 | + | write("Confirm Password: ") |
662 | - | term.setTextColor(colors.yellow) |
662 | + | term.setTextColor(colors.white) |
663 | - | write("Confirm Password: ") |
663 | + | ConfirmPassword = read("*") |
664 | - | term.setTextColor(colors.white) |
664 | + | if Password == ConfirmPassword then |
665 | - | ConfirmPassword = read("*") |
665 | + | break |
666 | - | if Password == ConfirmPassword then |
666 | + | else |
667 | - | break |
667 | + | term.setTextColor(colors.red) |
668 | - | else |
668 | + | write("\nPasswords Do Not Match!") |
669 | - | term.setTextColor(colors.red) |
669 | + | term.setTextColor(colors.white) |
670 | - | write("\nPasswords Do Not Match!") |
670 | + | end |
671 | - | term.setTextColor(colors.white) |
671 | + | until Password == ConfirmPassword |
672 | - | end |
672 | + | rednet.send(Server, "CreateUser") |
673 | - | until Password == ConfirmPassword |
673 | + | os.sleep(0.1) |
674 | - | rednet.send(Server, "CreateUser") |
674 | + | rednet.send(Server, Username) |
675 | - | os.sleep(0.1) |
675 | + | os.sleep(0.1) |
676 | - | rednet.send(Server, Username) |
676 | + | rednet.send(Server, Password) |
677 | - | os.sleep(0.1) |
677 | + | ID, Status = rednet.receive(5) |
678 | - | rednet.send(Server, Password) |
678 | + | if Status then |
679 | - | ID, Status = rednet.receive(5) |
679 | + | term.setTextColor(colors.lime) |
680 | - | if Status then |
680 | + | print("\nUser Account Created Successfully!") |
681 | - | term.setTextColor(colors.lime) |
681 | + | term.setTextColor(colors.yellow) |
682 | - | print("\nUser Account Created Successfully!") |
682 | + | print("\n(-)Ok") |
683 | - | term.setTextColor(colors.yellow) |
683 | + | term.setTextColor(colors.white) |
684 | - | print("\n(-)Ok") |
684 | + | repeat |
685 | - | term.setTextColor(colors.white) |
685 | + | event, key = os.pullEvent("key") |
686 | - | repeat |
686 | + | os.sleep(0.1) |
687 | - | event, key = os.pullEvent("key") |
687 | + | until key == 28 |
688 | - | os.sleep(0.1) |
688 | + | Back() |
689 | - | until key == 28 |
689 | + | else |
690 | - | Back() |
690 | + | term.setTextColor(colors.red) |
691 | - | else |
691 | + | print("\nThere Was An Error!\nThe Username Must Already Exist Or The E-Mail Server Is Not On!") |
692 | - | term.setTextColor(colors.red) |
692 | + | term.setTextColor(colors.yellow) |
693 | - | print("\nThere Was An Error!\nThe Username Must Already Exist Or The E-Mail Server Is Not On!") |
693 | + | print("\n(-)Ok") |
694 | - | term.setTextColor(colors.yellow) |
694 | + | term.setTextColor(colors.white) |
695 | - | print("\n(-)Ok") |
695 | + | repeat |
696 | - | term.setTextColor(colors.white) |
696 | + | event, key = os.pullEvent("key") |
697 | - | repeat |
697 | + | os.sleep(0.1) |
698 | - | event, key = os.pullEvent("key") |
698 | + | until key == 28 |
699 | - | os.sleep(0.1) |
699 | + | Back() |
700 | - | until key == 28 |
700 | + | end |
701 | - | Back() |
701 | + | |
702 | - | end |
702 | + | |
703 | function DeleteUser() | |
704 | ResetL() | |
705 | print("Delete A User Account\n") | |
706 | - | ResetL() |
706 | + | term.setTextColor(colors.yellow) |
707 | - | print("Delete A User Account\n") |
707 | + | write("Enter The Username: ") |
708 | - | term.setTextColor(colors.yellow) |
708 | + | term.setTextColor(colors.white) |
709 | - | write("Enter The Username: ") |
709 | + | Username = read() |
710 | - | term.setTextColor(colors.white) |
710 | + | term.setTextColor(colors.yellow) |
711 | - | Username = read() |
711 | + | write("Enter The Password: ") |
712 | - | term.setTextColor(colors.yellow) |
712 | + | term.setTextColor(colors.white) |
713 | - | write("Enter The Password: ") |
713 | + | Password = read("*") |
714 | - | term.setTextColor(colors.white) |
714 | + | rednet.send(Server, "DeleteUser") |
715 | - | Password = read("*") |
715 | + | os.sleep(0.1) |
716 | - | rednet.send(Server, "DeleteUser") |
716 | + | rednet.send(Server, Username) |
717 | - | os.sleep(0.1) |
717 | + | os.sleep(0.1) |
718 | - | rednet.send(Server, Username) |
718 | + | rednet.send(Server, Password) |
719 | - | os.sleep(0.1) |
719 | + | ID, Success = rednet.receive(5) |
720 | - | rednet.send(Server, Password) |
720 | + | if Success then |
721 | - | ID, Success = rednet.receive(5) |
721 | + | if Success == "true" then |
722 | - | if Success then |
722 | + | term.setTextColor(colors.lime) |
723 | - | if Success == "true" then |
723 | + | print("\nUser Account Was Remove Successfully!") |
724 | - | term.setTextColor(colors.lime) |
724 | + | term.setTextColor(colors.yellow) |
725 | - | print("\nUser Account Was Remove Successfully!") |
725 | + | print("\n(-)Ok") |
726 | - | term.setTextColor(colors.yellow) |
726 | + | term.setTextColor(colors.white) |
727 | - | print("\n(-)Ok") |
727 | + | repeat |
728 | - | term.setTextColor(colors.white) |
728 | + | event, key = os.pullEvent("key") |
729 | - | repeat |
729 | + | os.sleep(0.1) |
730 | - | event, key = os.pullEvent("key") |
730 | + | until key == 28 |
731 | - | os.sleep(0.1) |
731 | + | Back() |
732 | - | until key == 28 |
732 | + | elseif Success == "false" then |
733 | - | Back() |
733 | + | term.setTextColor(colors.red) |
734 | - | elseif Success == "false" then |
734 | + | print("\nUser Account Couldn't Be Deleted!\nMake Sure The Username And Password Are Correct!") |
735 | - | term.setTextColor(colors.red) |
735 | + | term.setTextColor(colors.yellow) |
736 | - | print("\nUser Account Couldn't Be Deleted!\nMake Sure The Username And Password Are Correct!") |
736 | + | print("\n(-)Ok") |
737 | - | term.setTextColor(colors.yellow) |
737 | + | term.setTextColor(colors.white) |
738 | - | print("\n(-)Ok") |
738 | + | repeat |
739 | - | term.setTextColor(colors.white) |
739 | + | event, key = os.pullEvent("key") |
740 | - | repeat |
740 | + | os.sleep(0.1) |
741 | - | event, key = os.pullEvent("key") |
741 | + | until key == 28 |
742 | - | os.sleep(0.1) |
742 | + | Back() |
743 | - | until key == 28 |
743 | + | end |
744 | - | Back() |
744 | + | else |
745 | - | end |
745 | + | term.setTextColor(colors.red) |
746 | - | else |
746 | + | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
747 | - | term.setTextColor(colors.red) |
747 | + | term.setTextColor(colors.yellow) |
748 | - | print("\nThere Was An Error!\nMake Sure The E-Mail Server Is Turned On!") |
748 | + | print("\n(-)Ok") |
749 | - | term.setTextColor(colors.yellow) |
749 | + | term.setTextColor(colors.white) |
750 | - | print("\n(-)Ok") |
750 | + | repeat |
751 | - | term.setTextColor(colors.white) |
751 | + | event, key = os.pullEvent("key") |
752 | - | repeat |
752 | + | os.sleep(0.1) |
753 | - | event, key = os.pullEvent("key") |
753 | + | until key == 28 |
754 | - | os.sleep(0.1) |
754 | + | Back() |
755 | - | until key == 28 |
755 | + | end |
756 | - | Back() |
756 | + | |
757 | - | end |
757 | + | |
758 | function Options() | |
759 | SelectedItem = 1 | |
760 | UseOptionsMenu = true UseMainMenu = false UseLoginMenu = false | |
761 | - | SelectedItem = 1 |
761 | + | while UseOptionsMenu do |
762 | - | UseOptionsMenu = true UseMainMenu = false UseLoginMenu = false |
762 | + | ResetL() |
763 | - | while UseOptionsMenu do |
763 | + | print("Options\n") |
764 | - | ResetL() |
764 | + | PrintMenu(OptionsMenu) |
765 | - | print("Options\n") |
765 | + | |
766 | - | PrintMenu(OptionsMenu) |
766 | + | event, key = os.pullEvent("key") |
767 | - | |
767 | + | KeyHandler(key, OptionsMenu) |
768 | - | event, key = os.pullEvent("key") |
768 | + | end |
769 | - | KeyHandler(key, OptionsMenu) |
769 | + | |
770 | - | end |
770 | + | |
771 | function Network() | |
772 | SelectedItem = 1 | |
773 | if LoggedIn then | |
774 | - | SelectedItem = 1 |
774 | + | UseMainMenu = true UseLoginMenu = false UseMessagesMenu = false UseOptionsMenu = false |
775 | - | if LoggedIn then |
775 | + | while UseMainMenu do |
776 | - | UseMainMenu = true UseLoginMenu = false UseMessagesMenu = false UseOptionsMenu = false |
776 | + | Reset() |
777 | - | while UseMainMenu do |
777 | + | print("Main Menu\n") |
778 | - | Reset() |
778 | + | PrintMenu(MainMenu) |
779 | - | print("Main Menu\n") |
779 | + | |
780 | - | PrintMenu(MainMenu) |
780 | + | event, key = os.pullEvent("key") |
781 | - | |
781 | + | KeyHandler(key, MainMenu) |
782 | - | event, key = os.pullEvent("key") |
782 | + | end |
783 | - | KeyHandler(key, MainMenu) |
783 | + | else |
784 | - | end |
784 | + | UseLoginMenu = true UseMainMenu = false |
785 | - | else |
785 | + | while UseLoginMenu do |
786 | - | UseLoginMenu = true UseMainMenu = false |
786 | + | ResetL() |
787 | - | while UseLoginMenu do |
787 | + | print("Welcome!\n") |
788 | - | ResetL() |
788 | + | PrintMenu(LoginMenu) |
789 | - | print("Welcome!\n") |
789 | + | |
790 | - | PrintMenu(LoginMenu) |
790 | + | event, key = os.pullEvent("key") |
791 | - | |
791 | + | KeyHandler(key, LoginMenu) |
792 | - | event, key = os.pullEvent("key") |
792 | + | end |
793 | - | KeyHandler(key, LoginMenu) |
793 | + | end |
794 | - | end |
794 | + | |
795 | - | end |
795 | + | |
796 | --[[ Tables ]]-- | |
797 | -- Menus -- | |
798 | LoginMenu = { | |
799 | [1] = { Option = "Log In\n", Function = LogIn }, | |
800 | [2] = { Option = "Options", Function = Options }, | |
801 | - | [1] = { Option = "Log In\n", Function = LogIn }, |
801 | + | [3] = { Option = "Reboot", Function = Reboot }, |
802 | - | [2] = { Option = "Options", Function = Options }, |
802 | + | [4] = { Option = "Shutdown", Function = Shutdown } |
803 | - | [3] = { Option = "Reboot", Function = Reboot }, |
803 | + | |
804 | - | [4] = { Option = "Shutdown", Function = Shutdown } |
804 | + | |
805 | MainMenu = { | |
806 | [1] = { Option = "Send A Message", Function = SendMessage }, | |
807 | [2] = { Option = "Inbox", Function = Inbox }, | |
808 | - | [1] = { Option = "Send A Message", Function = SendMessage }, |
808 | + | [3] = { Option = "Logout", Function = LogOut } |
809 | - | [2] = { Option = "Inbox", Function = Inbox }, |
809 | + | |
810 | - | [3] = { Option = "Logout", Function = LogOut } |
810 | + | |
811 | OptionsMenu = { | |
812 | [1] = { Option = "Set E-Mail Server ID", Function = SetID }, | |
813 | [2] = { Option = "Create New User", Function = NewUser }, | |
814 | - | [1] = { Option = "Set E-Mail Server ID", Function = SetID }, |
814 | + | [3] = { Option = "Delete A User\n", Function = DeleteUser }, |
815 | - | [2] = { Option = "Create New User", Function = NewUser }, |
815 | + | [4] = { Option = "Back" } |
816 | - | [3] = { Option = "Delete A User\n", Function = DeleteUser }, |
816 | + | |
817 | - | [4] = { Option = "Back" } |
817 | + | |
818 | --[[ Start The Program ]]-- | |
819 | os.pullEvet = os.pullEventRaw | |
820 | if peripheral.isPresent("right") and peripheral.getType("right") == "modem" then | |
821 | rednet.open("right") | |
822 | DoNetwork = true | |
823 | - | rednet.open("right") |
823 | + | |
824 | - | DoNetwork = true |
824 | + | rednet.open("left") |
825 | DoNetwork = true | |
826 | - | rednet.open("left") |
826 | + | |
827 | - | DoNetwork = true |
827 | + | rednet.open("top") |
828 | DoNetwork = true | |
829 | - | rednet.open("top") |
829 | + | |
830 | - | DoNetwork = true |
830 | + | rednet.open("bottom") |
831 | DoNetwork = true | |
832 | - | rednet.open("bottom") |
832 | + | |
833 | - | DoNetwork = true |
833 | + | rednet.open("front") |
834 | DoNetwork = true | |
835 | - | rednet.open("front") |
835 | + | |
836 | - | DoNetwork = true |
836 | + | rednet.open("back") |
837 | DoNetwork = true | |
838 | - | rednet.open("back") |
838 | + | |
839 | - | DoNetwork = true |
839 | + | ResetL() |
840 | term.setTextColor(colors.red) | |
841 | - | ResetL() |
841 | + | print("You must place a modem on the computer before you can use E-Mail!") |
842 | - | term.setTextColor(colors.red) |
842 | + | term.setTextColor(colors.white) |
843 | - | print("You must place a modem on the computer before you can use E-Mail!") |
843 | + | |
844 | - | term.setTextColor(colors.white) |
844 | + | |
845 | Network() | |
846 | end | |
847 | - | Network() |
847 | + | Startup = -- Local Variables -- |
848 | Root = ".Network/" | |
849 | - | Startup = http.get("http://dl.dropbox.com/u/39147094/E-Mail%20Network/Client/Startup") |
849 | + | |
850 | -- Interface -- | |
851 | shell.run(Root .. "Network.lua") | |
852 | ||
853 | f = fs.open("startup", "w") | |
854 | f.write(Startup.readAll()) | |
855 | f.close() | |
856 | f = fs.open(Root .. "Network.lua", "w") | |
857 | f.write(Network.readAll()) | |
858 | f.close() | |
859 | term.setTextColor(colors.lime) | |
860 | print("\nDone!") | |
861 | os.sleep(1) | |
862 | Reset() | |
863 | print("E-Mail Server Downloaded Successfully!\nEdition: Client") | |
864 | term.setTextColor(colors.yellow) | |
865 | print("\n(-)Ok") | |
866 | term.setTextColor(colors.white) | |
867 | repeat | |
868 | event, key = os.pullEvent("key") | |
869 | os.sleep(0.1) | |
870 | until key == 28 | |
871 | os.reboot() |