SHOW:
|
|
- or go back to the newest paste.
1 | --[[This is a fix of the original version (https://pastebin.com/knPtJCjb). Thanks to https://pastebin.com/dyre9saS and https://pastebin.com/gyMNUyRb for providing a fix to the clock while I was distracted from this project. I've remade the getTime function to make it work with Timezones again]] | |
2 | local mon = peripheral.find("monitor") | |
3 | local core = peripheral.find("draconic_rf_storage") | |
4 | local tier = 0 | |
5 | local colorShield = colors.white | |
6 | local colorCore = colors.white | |
7 | local input, output = peripheral.find("flux_gate") | |
8 | local limitTransfer = true | |
9 | local currentControls = "main" | |
10 | local page = 1 | |
11 | local putLimit = "" | |
12 | local version = "1.0" | |
13 | - | local timediff = 0 |
13 | + | |
14 | - | local monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31} |
14 | + | |
15 | else | |
16 | file = io.open("logs.cfg", "w") | |
17 | file:write("") | |
18 | file:close() | |
19 | end | |
20 | ||
21 | if fs.exists("config.cfg") then | |
22 | else | |
23 | file = io.open("config.cfg", "w") | |
24 | file:write("Timezone: 0") | |
25 | file:close() | |
26 | end | |
27 | ||
28 | mon.setTextScale(1) | |
29 | ||
30 | local function fileWrite(path, text) | |
31 | local file = io.open(path, "w") | |
32 | file:write(text) | |
33 | file:close() | |
34 | end | |
35 | ||
36 | local function fileWriteFromTable(path, t) | |
37 | local text = "" | |
38 | for _, line in pairs(t) do | |
39 | text = text..line.."\n" | |
40 | end | |
41 | fileWrite(path, text) | |
42 | end | |
43 | ||
44 | local function fileGetTable(path) | |
45 | if fs.exists(path) then | |
46 | local file = io.open(path, "r") | |
47 | local lines = {} | |
48 | local i = 1 | |
49 | local line = file:read("*l") | |
50 | while line ~= nil do | |
51 | lines[i] = line | |
52 | line = file:read("*l") | |
53 | i = i +1 | |
54 | end | |
55 | file:close() | |
56 | return lines | |
57 | end | |
58 | return {} | |
59 | end | |
60 | ||
61 | local function fileReplaceLine(path, n, text) | |
62 | local lines = fileGetTable(path) | |
63 | lines[n] = text | |
64 | fileWriteFromTable(path, lines) | |
65 | end | |
66 | ||
67 | local function fileAppend(path, text) | |
68 | local file = io.open(path, "a") | |
69 | file:write(text.."\n") | |
70 | file:close() | |
71 | end | |
72 | ||
73 | local function fileGetLength(path) | |
74 | local file = io.open(path, "r") | |
75 | local i = 0 | |
76 | while file:read("*l") ~= nil do | |
77 | i = i +1 | |
78 | end | |
79 | file:close() | |
80 | return i | |
81 | end | |
82 | ||
83 | local function fileGetLines(path, startN, endN) | |
84 | local lines = fileGetTable(path) | |
85 | local linesOut = {} | |
86 | local x = 1 | |
87 | for i = startN, endN, 1 do | |
88 | linesOut[x] = lines[i] | |
89 | x = x + 1 | |
90 | end | |
91 | return linesOut | |
92 | end | |
93 | ||
94 | local function editConfigFile(path,line,text) | |
95 | fileReplaceLine(path,line,text) | |
96 | end | |
97 | ||
98 | local function detectInOutput() | |
99 | input, output = peripheral.find("flux_gate") | |
100 | --print(input) | |
101 | --print(output) | |
102 | if core.getTransferPerTick() ~= 0 then | |
103 | if core.getTransferPerTick() < 0 then | |
104 | output.setSignalLowFlow(0) | |
105 | sleep(2) | |
106 | if core.getTransferPerTick() >= 0 then | |
107 | --keep it | |
108 | else | |
109 | output, input = peripheral.find("flux_gate") | |
110 | end | |
111 | output.setSignalLowFlow(2147483647) | |
112 | input.setSignalLowFlow(2147483647) | |
113 | elseif core.getTransferPerTick() > 0 then | |
114 | input.setSignalLowFlow(0) | |
115 | sleep(2) | |
116 | if core.getTransferPerTick() <= 0 then | |
117 | --keep it | |
118 | else | |
119 | output, input = peripheral.find("flux_gate") | |
120 | end | |
121 | output.setSignalLowFlow(2147483647) | |
122 | input.setSignalLowFlow(2147483647) | |
123 | end | |
124 | end | |
125 | end | |
126 | ||
127 | if peripheral.find("flux_gate") == nil then | |
128 | limitTransfer = false | |
129 | else | |
130 | limitTransfer = true | |
131 | detectInOutput() | |
132 | end | |
133 | ||
134 | local function makeNumber2Digits(number) | |
135 | strNumber = tostring(number) | |
136 | if string.len(strNumber) == 1 then | |
137 | return "0" .. strNumber | |
138 | else | |
139 | return string.sub(strNumber, string.len(strNumber) - 2) | |
140 | end | |
141 | end | |
142 | ||
143 | local function getLogs(path, xPos, yPos) | |
144 | local Logs = fileGetLines(path, fileGetLength(path)-5, fileGetLength(path)) | |
145 | for i = 1, 6, 1 do | |
146 | mon.setCursorPos(xPos+2,yPos+1+i) | |
147 | mon.write(Logs[i]) | |
148 | end | |
149 | end | |
150 | ||
151 | local function addLog(path, time, text) | |
152 | fileAppend(path, "["..time.."]") | |
153 | fileAppend(path, text) | |
154 | end | |
155 | ||
156 | local function round(num, idp) | |
157 | local mult = 10^(idp or 0) | |
158 | return math.floor(num * mult + 0.5) / mult | |
159 | end | |
160 | ||
161 | local function convertRF(rf) | |
162 | rfString = "" | |
163 | if rf < 1000 then | |
164 | rfString = tostring(rf) | |
165 | elseif rf < 1000000 then | |
166 | rfString = tostring(round((rf/1000),1)).."k" | |
167 | elseif rf < 1000000000 then | |
168 | rfString = tostring(round((rf/1000000),1)).."M" | |
169 | elseif rf < 1000000000000 then | |
170 | rfString = tostring(round((rf/1000000000),1)).."G" | |
171 | elseif rf < 1000000000000000 then | |
172 | rfString = tostring(round((rf/1000000000000),1)).."T" | |
173 | elseif rf < 1000000000000000000 then | |
174 | rfString = tostring(round((rf/1000000000000000),1)).."P" | |
175 | elseif rf < 1000000000000000000000 then | |
176 | rfString = tostring(round((rf/1000000000000000000),1)).."E" | |
177 | end | |
178 | return(rfString.."RF") | |
179 | end | |
180 | ||
181 | local function drawL1(xPos, yPos) | |
182 | mon.setCursorPos(xPos, yPos) | |
183 | mon.setBackgroundColor(colorCore) | |
184 | mon.write(" ") | |
185 | mon.setCursorPos(xPos, yPos+1) | |
186 | mon.write(" ") | |
187 | mon.setCursorPos(xPos, yPos+2) | |
188 | mon.write(" ") | |
189 | mon.setCursorPos(xPos, yPos+3) | |
190 | mon.write(" ") | |
191 | mon.setCursorPos(xPos, yPos+4) | |
192 | mon.setBackgroundColor(colorShield) | |
193 | mon.write(" ") | |
194 | mon.setCursorPos(xPos, yPos+5) | |
195 | mon.setBackgroundColor(colorCore) | |
196 | mon.write(" ") | |
197 | mon.setCursorPos(xPos, yPos+6) | |
198 | mon.write(" ") | |
199 | mon.setCursorPos(xPos, yPos+7) | |
200 | mon.setBackgroundColor(colorShield) | |
201 | mon.write(" ") | |
202 | mon.setCursorPos(xPos, yPos+8) | |
203 | mon.setBackgroundColor(colorCore) | |
204 | mon.write(" ") | |
205 | end | |
206 | ||
207 | local function drawL2(xPos, yPos) | |
208 | mon.setCursorPos(xPos, yPos) | |
209 | mon.setBackgroundColor(colorCore) | |
210 | mon.write(" ") | |
211 | mon.setCursorPos(xPos, yPos+1) | |
212 | mon.write(" ") | |
213 | mon.setCursorPos(xPos, yPos+2) | |
214 | mon.write(" ") | |
215 | mon.setCursorPos(xPos, yPos+3) | |
216 | mon.write(" ") | |
217 | mon.setCursorPos(xPos, yPos+4) | |
218 | mon.write(" ") | |
219 | mon.setCursorPos(xPos, yPos+5) | |
220 | mon.setBackgroundColor(colorShield) | |
221 | mon.write(" ") | |
222 | mon.setCursorPos(xPos, yPos+6) | |
223 | mon.setBackgroundColor(colorCore) | |
224 | mon.write(" ") | |
225 | mon.setCursorPos(xPos, yPos+7) | |
226 | mon.write(" ") | |
227 | mon.setCursorPos(xPos, yPos+8) | |
228 | mon.write(" ") | |
229 | end | |
230 | ||
231 | local function drawL3(xPos, yPos) | |
232 | mon.setCursorPos(xPos, yPos) | |
233 | mon.setBackgroundColor(colorCore) | |
234 | mon.write(" ") | |
235 | mon.setCursorPos(xPos, yPos+1) | |
236 | mon.write(" ") | |
237 | mon.setCursorPos(xPos, yPos+2) | |
238 | mon.setBackgroundColor(colorShield) | |
239 | mon.write(" ") | |
240 | mon.setCursorPos(xPos, yPos+3) | |
241 | mon.setBackgroundColor(colorCore) | |
242 | mon.write(" ") | |
243 | mon.setCursorPos(xPos, yPos+4) | |
244 | mon.write(" ") | |
245 | mon.setCursorPos(xPos, yPos+5) | |
246 | mon.write(" ") | |
247 | mon.setCursorPos(xPos, yPos+6) | |
248 | mon.setBackgroundColor(colorShield) | |
249 | mon.write(" ") | |
250 | mon.setCursorPos(xPos, yPos+7) | |
251 | mon.setBackgroundColor(colorCore) | |
252 | mon.write(" ") | |
253 | mon.setCursorPos(xPos, yPos+8) | |
254 | mon.write(" ") | |
255 | end | |
256 | ||
257 | local function drawL4(xPos, yPos) | |
258 | mon.setCursorPos(xPos, yPos) | |
259 | mon.setBackgroundColor(colorCore) | |
260 | mon.write(" ") | |
261 | mon.setCursorPos(xPos, yPos+1) | |
262 | mon.write(" ") | |
263 | mon.setCursorPos(xPos, yPos+2) | |
264 | mon.write(" ") | |
265 | mon.setCursorPos(xPos, yPos+3) | |
266 | mon.setBackgroundColor(colorShield) | |
267 | mon.write(" ") | |
268 | mon.setCursorPos(xPos, yPos+4) | |
269 | mon.setBackgroundColor(colorCore) | |
270 | mon.write(" ") | |
271 | mon.setCursorPos(xPos, yPos+5) | |
272 | mon.write(" ") | |
273 | mon.setCursorPos(xPos, yPos+6) | |
274 | mon.write(" ") | |
275 | mon.setCursorPos(xPos, yPos+7) | |
276 | mon.setBackgroundColor(colorShield) | |
277 | mon.write(" ") | |
278 | mon.setCursorPos(xPos, yPos+8) | |
279 | mon.setBackgroundColor(colorCore) | |
280 | mon.write(" ") | |
281 | end | |
282 | ||
283 | local function drawL5(xPos, yPos) | |
284 | mon.setCursorPos(xPos, yPos) | |
285 | mon.setBackgroundColor(colorShield) | |
286 | mon.write(" ") | |
287 | mon.setCursorPos(xPos, yPos+1) | |
288 | mon.setBackgroundColor(colorCore) | |
289 | mon.write(" ") | |
290 | mon.setCursorPos(xPos, yPos+2) | |
291 | mon.write(" ") | |
292 | mon.setCursorPos(xPos, yPos+3) | |
293 | mon.write(" ") | |
294 | mon.setCursorPos(xPos, yPos+4) | |
295 | mon.write(" ") | |
296 | mon.setCursorPos(xPos, yPos+5) | |
297 | mon.write(" ") | |
298 | mon.setCursorPos(xPos, yPos+6) | |
299 | mon.write(" ") | |
300 | mon.setCursorPos(xPos, yPos+7) | |
301 | mon.write(" ") | |
302 | mon.setCursorPos(xPos, yPos+8) | |
303 | mon.write(" ") | |
304 | end | |
305 | ||
306 | local function drawL6(xPos, yPos) | |
307 | mon.setCursorPos(xPos, yPos) | |
308 | mon.setBackgroundColor(colorCore) | |
309 | mon.write(" ") | |
310 | mon.setCursorPos(xPos, yPos+1) | |
311 | mon.setBackgroundColor(colorShield) | |
312 | mon.write(" ") | |
313 | mon.setCursorPos(xPos, yPos+2) | |
314 | mon.setBackgroundColor(colorCore) | |
315 | mon.write(" ") | |
316 | mon.setCursorPos(xPos, yPos+3) | |
317 | mon.write(" ") | |
318 | mon.setCursorPos(xPos, yPos+4) | |
319 | mon.write(" ") | |
320 | mon.setCursorPos(xPos, yPos+5) | |
321 | mon.setBackgroundColor(colorShield) | |
322 | mon.write(" ") | |
323 | mon.setCursorPos(xPos, yPos+6) | |
324 | mon.setBackgroundColor(colorCore) | |
325 | mon.write(" ") | |
326 | mon.setCursorPos(xPos, yPos+7) | |
327 | mon.write(" ") | |
328 | mon.setCursorPos(xPos, yPos+8) | |
329 | mon.write(" ") | |
330 | end | |
331 | ||
332 | local function drawL7(xPos, yPos) | |
333 | mon.setCursorPos(xPos, yPos) | |
334 | mon.setBackgroundColor(colorCore) | |
335 | mon.write(" ") | |
336 | mon.setCursorPos(xPos, yPos+1) | |
337 | mon.write(" ") | |
338 | mon.setCursorPos(xPos, yPos+2) | |
339 | mon.write(" ") | |
340 | mon.setCursorPos(xPos, yPos+3) | |
341 | mon.setBackgroundColor(colorShield) | |
342 | mon.write(" ") | |
343 | mon.setCursorPos(xPos, yPos+4) | |
344 | mon.setBackgroundColor(colorCore) | |
345 | mon.write(" ") | |
346 | mon.setCursorPos(xPos, yPos+5) | |
347 | mon.write(" ") | |
348 | mon.setCursorPos(xPos, yPos+6) | |
349 | mon.setBackgroundColor(colorShield) | |
350 | mon.write(" ") | |
351 | mon.setCursorPos(xPos, yPos+7) | |
352 | mon.setBackgroundColor(colorCore) | |
353 | mon.write(" ") | |
354 | mon.setCursorPos(xPos, yPos+8) | |
355 | mon.setBackgroundColor(colorShield) | |
356 | mon.write(" ") | |
357 | end | |
358 | ||
359 | local function drawL8(xPos, yPos) | |
360 | mon.setCursorPos(xPos, yPos) | |
361 | mon.setBackgroundColor(colorCore) | |
362 | mon.write(" ") | |
363 | mon.setCursorPos(xPos, yPos+1) | |
364 | mon.write(" ") | |
365 | mon.setCursorPos(xPos, yPos+2) | |
366 | mon.write(" ") | |
367 | mon.setCursorPos(xPos, yPos+3) | |
368 | mon.write(" ") | |
369 | mon.setCursorPos(xPos, yPos+4) | |
370 | mon.setBackgroundColor(colorShield) | |
371 | mon.write(" ") | |
372 | mon.setCursorPos(xPos, yPos+5) | |
373 | mon.setBackgroundColor(colorCore) | |
374 | mon.write(" ") | |
375 | mon.setCursorPos(xPos, yPos+6) | |
376 | mon.write(" ") | |
377 | mon.setCursorPos(xPos, yPos+7) | |
378 | mon.write(" ") | |
379 | mon.setCursorPos(xPos, yPos+8) | |
380 | mon.write(" ") | |
381 | end | |
382 | ||
383 | local function drawL9(xPos, yPos) | |
384 | mon.setCursorPos(xPos, yPos) | |
385 | mon.setBackgroundColor(colorCore) | |
386 | mon.write(" ") | |
387 | mon.setCursorPos(xPos, yPos+1) | |
388 | mon.setBackgroundColor(colorShield) | |
389 | mon.write(" ") | |
390 | mon.setCursorPos(xPos, yPos+2) | |
391 | mon.setBackgroundColor(colorCore) | |
392 | mon.write(" ") | |
393 | mon.setCursorPos(xPos, yPos+3) | |
394 | mon.write(" ") | |
395 | mon.setCursorPos(xPos, yPos+4) | |
396 | mon.write(" ") | |
397 | mon.setCursorPos(xPos, yPos+5) | |
398 | mon.write(" ") | |
399 | mon.setCursorPos(xPos, yPos+6) | |
400 | mon.write(" ") | |
401 | mon.setCursorPos(xPos, yPos+7) | |
402 | mon.setBackgroundColor(colorShield) | |
403 | mon.write(" ") | |
404 | mon.setCursorPos(xPos, yPos+8) | |
405 | mon.setBackgroundColor(colorCore) | |
406 | mon.write(" ") | |
407 | end | |
408 | ||
409 | local function drawL10(xPos, yPos) | |
410 | mon.setCursorPos(xPos, yPos) | |
411 | mon.setBackgroundColor(colorCore) | |
412 | mon.write(" ") | |
413 | mon.setCursorPos(xPos, yPos+1) | |
414 | mon.write(" ") | |
415 | mon.setCursorPos(xPos, yPos+2) | |
416 | mon.setBackgroundColor(colorShield) | |
417 | mon.write(" ") | |
418 | mon.setCursorPos(xPos, yPos+3) | |
419 | mon.setBackgroundColor(colorCore) | |
420 | mon.write(" ") | |
421 | mon.setCursorPos(xPos, yPos+4) | |
422 | mon.write(" ") | |
423 | mon.setCursorPos(xPos, yPos+5) | |
424 | mon.setBackgroundColor(colorShield) | |
425 | mon.write(" ") | |
426 | mon.setCursorPos(xPos, yPos+6) | |
427 | mon.setBackgroundColor(colorCore) | |
428 | mon.write(" ") | |
429 | mon.setCursorPos(xPos, yPos+7) | |
430 | mon.write(" ") | |
431 | mon.setCursorPos(xPos, yPos+8) | |
432 | mon.setBackgroundColor(colorShield) | |
433 | mon.write(" ") | |
434 | end | |
435 | ||
436 | local function drawL11(xPos, yPos) | |
437 | mon.setCursorPos(xPos, yPos) | |
438 | mon.setBackgroundColor(colorCore) | |
439 | mon.write(" ") | |
440 | mon.setCursorPos(xPos, yPos+1) | |
441 | mon.write(" ") | |
442 | mon.setCursorPos(xPos, yPos+2) | |
443 | mon.write(" ") | |
444 | mon.setCursorPos(xPos, yPos+3) | |
445 | mon.write(" ") | |
446 | mon.setCursorPos(xPos, yPos+4) | |
447 | mon.write(" ") | |
448 | mon.setCursorPos(xPos, yPos+5) | |
449 | mon.write(" ") | |
450 | mon.setCursorPos(xPos, yPos+6) | |
451 | mon.setBackgroundColor(colorShield) | |
452 | mon.write(" ") | |
453 | mon.setCursorPos(xPos, yPos+7) | |
454 | mon.setBackgroundColor(colorCore) | |
455 | mon.write(" ") | |
456 | mon.setCursorPos(xPos, yPos+8) | |
457 | mon.write(" ") | |
458 | end | |
459 | ||
460 | local function drawL12(xPos, yPos) | |
461 | mon.setCursorPos(xPos, yPos) | |
462 | mon.setBackgroundColor(colorShield) | |
463 | mon.write(" ") | |
464 | mon.setCursorPos(xPos, yPos+1) | |
465 | mon.setBackgroundColor(colorCore) | |
466 | mon.write(" ") | |
467 | mon.setCursorPos(xPos, yPos+2) | |
468 | mon.write(" ") | |
469 | mon.setCursorPos(xPos, yPos+3) | |
470 | mon.write(" ") | |
471 | mon.setCursorPos(xPos, yPos+4) | |
472 | mon.write(" ") | |
473 | mon.setCursorPos(xPos, yPos+5) | |
474 | mon.write(" ") | |
475 | mon.setCursorPos(xPos, yPos+6) | |
476 | mon.write(" ") | |
477 | mon.setCursorPos(xPos, yPos+7) | |
478 | mon.write(" ") | |
479 | mon.setCursorPos(xPos, yPos+8) | |
480 | mon.write(" ") | |
481 | end | |
482 | ||
483 | local function drawL13(xPos, yPos) | |
484 | mon.setCursorPos(xPos, yPos) | |
485 | mon.setBackgroundColor(colorCore) | |
486 | mon.write(" ") | |
487 | mon.setCursorPos(xPos, yPos+1) | |
488 | mon.write(" ") | |
489 | mon.setCursorPos(xPos, yPos+2) | |
490 | mon.write(" ") | |
491 | mon.setCursorPos(xPos, yPos+3) | |
492 | mon.setBackgroundColor(colorShield) | |
493 | mon.write(" ") | |
494 | mon.setCursorPos(xPos, yPos+4) | |
495 | mon.setBackgroundColor(colorCore) | |
496 | mon.write(" ") | |
497 | mon.setCursorPos(xPos, yPos+5) | |
498 | mon.write(" ") | |
499 | mon.setCursorPos(xPos, yPos+6) | |
500 | mon.setBackgroundColor(colorShield) | |
501 | mon.write(" ") | |
502 | mon.setCursorPos(xPos, yPos+7) | |
503 | mon.setBackgroundColor(colorCore) | |
504 | mon.write(" ") | |
505 | mon.setCursorPos(xPos, yPos+8) | |
506 | mon.write(" ") | |
507 | end | |
508 | ||
509 | local function drawBox(xMin, xMax, yMin, yMax, title) | |
510 | mon.setBackgroundColor(colors.gray) | |
511 | for xPos = xMin, xMax, 1 do | |
512 | mon.setCursorPos(xPos, yMin) | |
513 | mon.write(" ") | |
514 | end | |
515 | for yPos = yMin, yMax, 1 do | |
516 | mon.setCursorPos(xMin, yPos) | |
517 | mon.write(" ") | |
518 | mon.setCursorPos(xMax, yPos) | |
519 | mon.write(" ") | |
520 | end | |
521 | for xPos = xMin, xMax, 1 do | |
522 | mon.setCursorPos(xPos, yMax) | |
523 | mon.write(" ") | |
524 | end | |
525 | mon.setCursorPos(xMin+2, yMin) | |
526 | mon.setBackgroundColor(colors.black) | |
527 | mon.write(" ") | |
528 | mon.write(title) | |
529 | mon.write(" ") | |
530 | end | |
531 | ||
532 | local function drawButton(xMin, xMax, yMin, yMax, text1, text2, bcolor) | |
533 | mon.setBackgroundColor(bcolor) | |
534 | for yPos = yMin, yMax, 1 do | |
535 | for xPos = xMin, xMax, 1 do | |
536 | mon.setCursorPos(xPos, yPos) | |
537 | mon.write(" ") | |
538 | end | |
539 | end | |
540 | mon.setCursorPos(math.floor((((xMax+xMin)/2)+0.5)-string.len(text1)/2),math.floor(((yMax+yMin)/2))) | |
541 | mon.write(text1) | |
542 | if text2 == nil then | |
543 | else | |
544 | mon.setCursorPos(math.floor((((xMax+xMin)/2)+0.5)-string.len(text2)/2),math.floor(((yMax+yMin)/2)+0.5)) | |
545 | mon.write(text2) | |
546 | end | |
547 | mon.setBackgroundColor(colors.black) | |
548 | end | |
549 | ||
550 | local function drawClear(xMin, xMax, yMin, yMax) | |
551 | mon.setBackgroundColor(colors.black) | |
552 | for yPos = yMin, yMax, 1 do | |
553 | for xPos = xMin, xMax, 1 do | |
554 | mon.setCursorPos(xPos, yPos) | |
555 | mon.write(" ") | |
556 | end | |
557 | end | |
558 | end | |
559 | ||
560 | local function drawNumpad(xPos ,yPos) | |
561 | mon.setCursorPos(xPos+2,yPos+4) | |
562 | mon.setBackgroundColor(colors.lightGray) | |
563 | mon.write(" 1 ") | |
564 | mon.setBackgroundColor(colors.gray) | |
565 | mon.write(" ") | |
566 | mon.setCursorPos(xPos+6,yPos+4) | |
567 | mon.setBackgroundColor(colors.lightGray) | |
568 | mon.write(" 2 ") | |
569 | mon.setBackgroundColor(colors.gray) | |
570 | mon.write(" ") | |
571 | mon.setCursorPos(xPos+10,yPos+4) | |
572 | mon.setBackgroundColor(colors.lightGray) | |
573 | mon.write(" 3 ") | |
574 | mon.setCursorPos(xPos+2,yPos+5) | |
575 | mon.setBackgroundColor(colors.lightGray) | |
576 | mon.write(" 4 ") | |
577 | mon.setBackgroundColor(colors.gray) | |
578 | mon.write(" ") | |
579 | mon.setCursorPos(xPos+6,yPos+5) | |
580 | mon.setBackgroundColor(colors.lightGray) | |
581 | mon.write(" 5 ") | |
582 | mon.setBackgroundColor(colors.gray) | |
583 | mon.write(" ") | |
584 | mon.setCursorPos(xPos+10,yPos+5) | |
585 | mon.setBackgroundColor(colors.lightGray) | |
586 | mon.write(" 6 ") | |
587 | mon.setCursorPos(xPos+2,yPos+6) | |
588 | mon.setBackgroundColor(colors.lightGray) | |
589 | mon.write(" 7 ") | |
590 | mon.setBackgroundColor(colors.gray) | |
591 | mon.write(" ") | |
592 | mon.setCursorPos(xPos+6,yPos+6) | |
593 | mon.setBackgroundColor(colors.lightGray) | |
594 | mon.write(" 8 ") | |
595 | mon.setBackgroundColor(colors.gray) | |
596 | mon.write(" ") | |
597 | mon.setCursorPos(xPos+10,yPos+6) | |
598 | mon.setBackgroundColor(colors.lightGray) | |
599 | mon.write(" 9 ") | |
600 | mon.setCursorPos(xPos+2,yPos+7) | |
601 | mon.setBackgroundColor(colors.red) | |
602 | mon.write(" < ") | |
603 | mon.setBackgroundColor(colors.gray) | |
604 | mon.write(" ") | |
605 | mon.setCursorPos(xPos+6,yPos+7) | |
606 | mon.setBackgroundColor(colors.lightGray) | |
607 | mon.write(" 0 ") | |
608 | mon.setBackgroundColor(colors.gray) | |
609 | mon.write(" ") | |
610 | mon.setCursorPos(xPos+10,yPos+7) | |
611 | mon.setBackgroundColor(colors.red) | |
612 | mon.write(" X ") | |
613 | mon.setCursorPos(xPos+16,yPos+5) | |
614 | mon.setBackgroundColor(colors.lime) | |
615 | mon.write(" Apply") | |
616 | mon.setCursorPos(xPos+16,yPos+7) | |
617 | mon.setBackgroundColor(colors.red) | |
618 | mon.write("Cancel") | |
619 | mon.setBackgroundColor(colors.black) | |
620 | end | |
621 | local function drawControls(xPos, yPos) | |
622 | if currentControls == "main" then | |
623 | --drawClear(xPos+1,xPos+22,yPos+1,yPos+8) | |
624 | if limitTransfer == false then | |
625 | drawButton(xPos+2,xPos+9,yPos+2,yPos+3,"Edit","InputMax",colors.gray) | |
626 | drawButton(xPos+13,xPos+21,yPos+2,yPos+3,"Edit","OutputMax",colors.gray) | |
627 | else | |
628 | drawButton(xPos+2,xPos+9,yPos+2,yPos+3,"Edit","InputMax",colors.lime) | |
629 | drawButton(xPos+13,xPos+21,yPos+2,yPos+3,"Edit","OutputMax",colors.red) | |
630 | end | |
631 | drawButton(xPos+2,xPos+9,yPos+6,yPos+7,"Edit","Config",colorCore) | |
632 | drawButton(xPos+13,xPos+21,yPos+6,yPos+7,"No Use","Yet",colors.gray) | |
633 | elseif currentControls == "editInput" or currentControls == "editOutput" then | |
634 | --drawClear(xPos+1,xPos+22,yPos+1,yPos+8) | |
635 | mon.setCursorPos(xPos+2,yPos+2) | |
636 | if currentControls == "editInput" then | |
637 | mon.write("Edit Max Input Rate") | |
638 | else | |
639 | mon.write("Edit Max Output Rate") | |
640 | end | |
641 | mon.setCursorPos(xPos+2,yPos+3) | |
642 | mon.setBackgroundColor(colors.gray) | |
643 | mon.write("___________") | |
644 | if string.len(putLimit) >= 11 then | |
645 | putLimit = string.sub(putLimit,string.len(putLimit)-10) | |
646 | end | |
647 | if putLimit ~= "" then | |
648 | if tonumber(putLimit) <= 2147483647 then | |
649 | mon.setCursorPos(xPos+13-string.len(putLimit),yPos+3) | |
650 | mon.write(putLimit) | |
651 | putLimitNum = tonumber(putLimit) | |
652 | mon.setBackgroundColor(colors.black) | |
653 | fix = 0 | |
654 | if putLimitNum < 1000 then | |
655 | if string.len(putLimit) <= 3 then | |
656 | mon.setCursorPos(xPos+22-string.len(putLimit)-2,yPos+3) | |
657 | mon.write(putLimit) | |
658 | else | |
659 | mon.setCursorPos(xPos+22-4-2,yPos+3) | |
660 | mon.write(string.sub(putLimit,string.len(putLimit)-2)) | |
661 | end | |
662 | elseif putLimitNum < 1000000 then | |
663 | if (round((putLimitNum/1000),1)*10)/(round((putLimitNum/1000),0)) == 10 then | |
664 | fix = 2 | |
665 | end | |
666 | mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000),1)))-3-fix,yPos+3) | |
667 | mon.write(round((putLimitNum/1000),1)) | |
668 | mon.write("k") | |
669 | elseif putLimitNum < 1000000000 then | |
670 | --if putLimitNum == 1000000*i or putLimitNum == 10000000*i or putLimitNum == 100000000*i then | |
671 | if (round((putLimitNum/1000000),1)*10)/(round((putLimitNum/1000000),0)) == 10 then | |
672 | fix = 2 | |
673 | end | |
674 | mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000000),1)))-3-fix,yPos+3) | |
675 | mon.write(round((putLimitNum/1000000),1)) | |
676 | mon.write("M") | |
677 | elseif putLimitNum < 1000000000000 then | |
678 | if (round((putLimitNum/1000000000),1)*10)/(round((putLimitNum/1000000000),0)) == 10 then | |
679 | fix = 2 | |
680 | end | |
681 | mon.setCursorPos(xPos+22-string.len(tostring(round((putLimitNum/1000000000),1)))-3-fix,yPos+3) | |
682 | mon.write(round((putLimitNum/1000000000),1)) | |
683 | mon.write("G") | |
684 | end | |
685 | mon.write("RF") | |
686 | else | |
687 | putLimit = "2147483647" | |
688 | mon.setCursorPos(xPos+13-string.len(putLimit),yPos+3) | |
689 | mon.write(putLimit) | |
690 | mon.setCursorPos(xPos+22-6,yPos+3) | |
691 | mon.setBackgroundColor(colors.black) | |
692 | mon.write("2.1GRF") | |
693 | mon.setCursorPos(xPos+22-6,yPos+4) | |
694 | mon.write("(max)") | |
695 | ||
696 | end | |
697 | ||
698 | end | |
699 | drawNumpad(xPos, yPos) | |
700 | elseif currentControls == "editOutput" then | |
701 | elseif currentControls == "editConfig" then | |
702 | mon.setCursorPos(xPos+2,yPos+2) | |
703 | mon.write("Edit Config") | |
704 | if limitTransfer == true then | |
705 | drawButton(xPos+2,xPos+10,yPos+3,yPos+4,"Detect","Flux_Gate",colorCore) | |
706 | else | |
707 | drawButton(xPos+2,xPos+10,yPos+3,yPos+4,"Detect","Flux_Gate",colors.gray) | |
708 | end | |
709 | drawButton(xPos+14,xPos+21,yPos+3,yPos+4,"Edit","Timezone",colorCore) | |
710 | mon.setCursorPos(xPos+16,yPos+7) | |
711 | mon.setBackgroundColor(colors.red) | |
712 | mon.write("Cancel") | |
713 | mon.setCursorPos(xPos+2,yPos+7) | |
714 | mon.setBackgroundColor(colors.gray) | |
715 | mon.write("Prev") | |
716 | mon.setCursorPos(xPos+7,yPos+7) | |
717 | mon.write("Next") | |
718 | mon.setBackgroundColor(colors.black) | |
719 | elseif currentControls == "editTimezone" then | |
720 | mon.setCursorPos(xPos+2,yPos+2) | |
721 | mon.write("Type Differenz") | |
722 | mon.setCursorPos(xPos+5,yPos+4) | |
723 | mon.setBackgroundColor(colors.red) | |
724 | mon.write(" -1 ") | |
725 | mon.setBackgroundColor(colors.lightGray) | |
726 | mon.write(" ") | |
727 | mon.setBackgroundColor(colors.gray) | |
728 | mon.write(" ") | |
729 | if timediff >= -12 and timediff <= 12 then | |
730 | elseif timediff < -12 then | |
731 | timediff = -12 | |
732 | elseif timediff > 12 then | |
733 | timediff = 12 | |
734 | end | |
735 | mon.setCursorPos(xPos+13-string.len(tostring(timediff)),yPos+4) | |
736 | mon.setBackgroundColor(colors.gray) | |
737 | mon.write(tostring(timediff)) | |
738 | mon.setBackgroundColor(colors.lightGray) | |
739 | mon.write(" ") | |
740 | mon.setBackgroundColor(colors.lime) | |
741 | mon.write(" +1 ") | |
742 | mon.setCursorPos(xPos+9,yPos+7) | |
743 | mon.setBackgroundColor(colors.red) | |
744 | mon.write("Cancel") | |
745 | mon.setBackgroundColor(colors.black) | |
746 | mon.write(" ") | |
747 | mon.setBackgroundColor(colors.lime) | |
748 | mon.write(" Apply") | |
749 | mon.setBackgroundColor(colors.black) | |
750 | end | |
751 | end | |
752 | ||
753 | local function drawDetails(xPos, yPos) | |
754 | energyStored = core.getEnergyStored() | |
755 | energyMax = core.getMaxEnergyStored() | |
756 | energyTransfer = core.getTransferPerTick() | |
757 | if limitTransfer == true then | |
758 | inputRate = input.getFlow() | |
759 | outputRate = output.getFlow() | |
760 | end | |
761 | mon.setCursorPos(xPos, yPos) | |
762 | if energyMax < 50000000 then | |
763 | tier = 1 | |
764 | elseif energyMax < 300000000 then | |
765 | tier = 2 | |
766 | elseif energyMax < 2000000000 then | |
767 | tier = 3 | |
768 | elseif energyMax < 10000000000 then | |
769 | tier = 4 | |
770 | elseif energyMax < 50000000000 then | |
771 | tier = 5 | |
772 | elseif energyMax < 400000000000 then | |
773 | tier = 6 | |
774 | elseif energyMax < 3000000000000 then | |
775 | tier = 7 | |
776 | else | |
777 | tier = 8 | |
778 | end | |
779 | mon.write("Tier: ") | |
780 | mon.write(tier) | |
781 | mon.setCursorPos(xPos+7, yPos) | |
782 | mon.write(" ") | |
783 | mon.setCursorPos(xPos, yPos+1) | |
784 | mon.write("Stored: ") | |
785 | if energyStored < 1000 then | |
786 | mon.write(energyStored) | |
787 | elseif energyStored < 1000000 then | |
788 | mon.write(round((energyStored/1000),1)) | |
789 | mon.write("k") | |
790 | elseif energyStored < 1000000000 then | |
791 | mon.write(round((energyStored/1000000),1)) | |
792 | mon.write("M") | |
793 | elseif energyStored < 1000000000000 then | |
794 | mon.write(round((energyStored/1000000000),1)) | |
795 | mon.write("G") | |
796 | elseif energyStored < 1000000000000000 then | |
797 | mon.write(round((energyStored/1000000000000),1)) | |
798 | mon.write("T") | |
799 | elseif energyStored < 1000000000000000000 then | |
800 | mon.write(round((energyStored/1000000000000000),1)) | |
801 | mon.write("P") | |
802 | elseif energyStored < 1000000000000000000000 then | |
803 | mon.write(round((energyStored/1000000000000000000),1)) | |
804 | mon.write("E") | |
805 | end | |
806 | mon.write("RF") | |
807 | mon.write("/") | |
808 | if energyMax < 1000 then | |
809 | mon.write(energyMax) | |
810 | elseif energyMax < 1000000 then | |
811 | mon.write(round((energyMax/1000),1)) | |
812 | mon.write("k") | |
813 | elseif energyMax < 1000000000 then | |
814 | mon.write(round((energyMax/1000000),1)) | |
815 | mon.write("M") | |
816 | elseif energyMax < 1000000000000 then | |
817 | mon.write(round((energyMax/1000000000),1)) | |
818 | mon.write("G") | |
819 | elseif energyMax < 1000000000000000 then | |
820 | mon.write(round((energyMax/1000000000000),1)) | |
821 | mon.write("T") | |
822 | elseif energyMax < 1000000000000000000 then | |
823 | mon.write(round((energyMax/1000000000000000 ),1)) | |
824 | mon.write("P") | |
825 | elseif energyMax < 1000000000000000000000 then | |
826 | mon.write(round((energyMax/1000000000000000000),1)) | |
827 | mon.write("E") | |
828 | end | |
829 | mon.write("RF") | |
830 | mon.setCursorPos(xPos, yPos+2) | |
831 | mon.setBackgroundColor(colors.lightGray) | |
832 | for l = 1, 20, 1 do | |
833 | mon.write(" ") | |
834 | end | |
835 | mon.setCursorPos(xPos, yPos+2) | |
836 | mon.setBackgroundColor(colors.lime) | |
837 | for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do | |
838 | mon.write(" ") | |
839 | end | |
840 | mon.setCursorPos(xPos, yPos+3) | |
841 | mon.setBackgroundColor(colors.lightGray) | |
842 | for l = 1, 20, 1 do | |
843 | mon.write(" ") | |
844 | end | |
845 | mon.setCursorPos(xPos, yPos+3) | |
846 | mon.setBackgroundColor(colors.lime) | |
847 | for l = 0, round((((energyStored/energyMax)*10)*2)-1,0), 1 do | |
848 | mon.write(" ") | |
849 | end | |
850 | mon.setBackgroundColor(colors.black) | |
851 | mon.setCursorPos(xPos, yPos+4) | |
852 | mon.write(" ") | |
853 | if string.len(tostring(round((energyStored/energyMax)*100))) == 1 then | |
854 | if round((energyStored/energyMax)*100) <= 10 then | |
855 | mon.setCursorPos(xPos, yPos+4) | |
856 | mon.write(round((energyStored/energyMax)*100)) | |
857 | mon.setCursorPos(xPos+1, yPos+4) | |
858 | mon.write("% ") | |
859 | else | |
860 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5), yPos+4) | |
861 | mon.write(round((energyStored/energyMax)*100)) | |
862 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-10)/5)+1, yPos+4) | |
863 | mon.write("% ") | |
864 | end | |
865 | elseif string.len(tostring(round((energyStored/energyMax)*100))) == 2 then | |
866 | if round((energyStored/energyMax)*100) <= 15 then | |
867 | mon.setCursorPos(xPos, yPos+4) | |
868 | mon.write(round((energyStored/energyMax)*100)) | |
869 | mon.setCursorPos(xPos+2, yPos+4) | |
870 | mon.write("% ") | |
871 | else | |
872 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5), yPos+4) | |
873 | mon.write(round((energyStored/energyMax)*100)) | |
874 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-15)/5)+2, yPos+4) | |
875 | mon.write("% ") | |
876 | end | |
877 | elseif string.len(tostring(round((energyStored/energyMax)*100))) == 3 then | |
878 | if round((energyStored/energyMax)*100) <= 20 then | |
879 | mon.setCursorPos(xPos, yPos+4) | |
880 | mon.write(round((energyStored/energyMax)*100)) | |
881 | mon.setCursorPos(xPos+3, yPos+4) | |
882 | mon.write("% ") | |
883 | else | |
884 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5), yPos+4) | |
885 | mon.write(round((energyStored/energyMax)*100)) | |
886 | mon.setCursorPos(xPos+round((((energyStored/energyMax)*100)-20)/5)+3, yPos+4) | |
887 | mon.write("% ") | |
888 | end | |
889 | end | |
890 | mon.setCursorPos(xPos, yPos+5) | |
891 | mon.write("InputMax:") | |
892 | mon.setCursorPos(xPos, yPos+6) | |
893 | mon.write(" ") | |
894 | mon.setCursorPos(xPos, yPos+6) | |
895 | mon.setTextColor(colors.lime) | |
896 | if limitTransfer == true then | |
897 | if inputRate == 0 then | |
898 | mon.setTextColor(colors.red) | |
899 | end | |
900 | if inputRate < 1000 then | |
901 | mon.write(inputRate) | |
902 | elseif inputRate < 1000000 then | |
903 | mon.write(round((inputRate/1000),1)) | |
904 | mon.write("k") | |
905 | elseif inputRate < 1000000000 then | |
906 | mon.write(round((inputRate/1000000),1)) | |
907 | mon.write("M") | |
908 | elseif inputRate < 1000000000000 then | |
909 | mon.write(round((inputRate/1000000000),1)) | |
910 | mon.write("G") | |
911 | elseif inputRate < 1000000000000000 then | |
912 | mon.write(round((inputRate/1000000000000),1)) | |
913 | mon.write("T") | |
914 | elseif inputRate < 1000000000000000000 then | |
915 | mon.write(round((inputRate/1000000000000000 ),1)) | |
916 | mon.write("P") | |
917 | elseif inputRate < 1000000000000000000000 then | |
918 | mon.write(round((inputRate/1000000000000000000),1)) | |
919 | mon.write("E") | |
920 | end | |
921 | mon.write("RF") | |
922 | else | |
923 | mon.write("INFINITE") | |
924 | end | |
925 | mon.setTextColor(colors.white) | |
926 | mon.setCursorPos(xPos+12, yPos+5) | |
927 | mon.write("OutputMax:") | |
928 | mon.setCursorPos(xPos+12, yPos+6) | |
929 | mon.write(" ") | |
930 | mon.setTextColor(colors.red) | |
931 | mon.setCursorPos(xPos+12, yPos+6) | |
932 | if limitTransfer == true then | |
933 | if outputRate < 1000 then | |
934 | mon.write(outputRate) | |
935 | elseif outputRate < 1000000 then | |
936 | mon.write(round((outputRate/1000),1)) | |
937 | mon.write("k") | |
938 | elseif outputRate < 1000000000 then | |
939 | mon.write(round((outputRate/1000000),1)) | |
940 | mon.write("M") | |
941 | elseif outputRate < 1000000000000 then | |
942 | mon.write(round((outputRate/1000000000),1)) | |
943 | mon.write("G") | |
944 | elseif outputRate < 1000000000000000 then | |
945 | mon.write(round((outputRate/1000000000000),1)) | |
946 | mon.write("T") | |
947 | elseif outputRate < 1000000000000000000 then | |
948 | mon.write(round((outputRate/1000000000000000),1)) | |
949 | mon.write("P") | |
950 | elseif outputRate < 1000000000000000000000 then | |
951 | mon.write(round((outputRate/1000000000000000000),1)) | |
952 | mon.write("E") | |
953 | end | |
954 | mon.write("RF") | |
955 | else | |
956 | mon.write("INFINITE") | |
957 | end | |
958 | mon.setTextColor(colors.white) | |
959 | mon.setCursorPos(xPos, yPos+7) | |
960 | mon.write("Transfer:") | |
961 | mon.setCursorPos(xPos, yPos+8) | |
962 | if energyTransfer < 0 then | |
963 | mon.setTextColor(colors.red) | |
964 | if energyTransfer*(-1) < 1000 then | |
965 | mon.write(energyTransfer) | |
966 | elseif energyTransfer*(-1) < 1000000 then | |
967 | mon.write(round((energyTransfer/1000),1)) | |
968 | mon.write("k") | |
969 | elseif energyTransfer*(-1) < 1000000000 then | |
970 | mon.write(round((energyTransfer/1000000),1)) | |
971 | mon.write("M") | |
972 | elseif energyTransfer*(-1) < 1000000000000 then | |
973 | mon.write(round((energyTransfer/1000000000),1)) | |
974 | mon.write("G") | |
975 | elseif energyTransfer*(-1) < 1000000000000000 then | |
976 | mon.write(round((energyTransfer/1000000000000),1)) | |
977 | mon.write("T") | |
978 | elseif energyTransfer*(-1) < 1000000000000000000 then | |
979 | mon.write(round((energyTransfer/1000000000000000),1)) | |
980 | mon.write("P") | |
981 | elseif energyTransfer*(-1) < 1000000000000000000000 then | |
982 | mon.write(round((energyTransfer/1000000000000000000),1)) | |
983 | mon.write("E") | |
984 | end | |
985 | elseif energyTransfer == 0 then | |
986 | mon.setTextColor(colors.red) | |
987 | mon.write("0") | |
988 | else | |
989 | mon.setTextColor(colors.lime) | |
990 | if energyTransfer < 1000 then | |
991 | mon.write(energyTransfer) | |
992 | elseif energyTransfer < 1000000 then | |
993 | mon.write(round((energyTransfer/1000),1)) | |
994 | mon.write("k") | |
995 | elseif energyTransfer < 1000000000 then | |
996 | mon.write(round((energyTransfer/1000000),1)) | |
997 | mon.write("M") | |
998 | elseif energyTransfer < 1000000000000 then | |
999 | mon.write(round((energyTransfer/1000000000),1)) | |
1000 | mon.write("G") | |
1001 | elseif energyTransfer < 1000000000000000 then | |
1002 | mon.write(round((energyTransfer/1000000000000),1)) | |
1003 | mon.write("T") | |
1004 | elseif energyTransfer < 1000000000000000000 then | |
1005 | mon.write(round((energyTransfer/1000000000000000),1)) | |
1006 | mon.write("P") | |
1007 | elseif energyTransfer < 1000000000000000000000 then | |
1008 | mon.write(round((energyTransfer/1000000000000000000),1)) | |
1009 | mon.write("E") | |
1010 | end | |
1011 | end | |
1012 | mon.write("RF") | |
1013 | mon.setTextColor(colors.white) | |
1014 | mon.setCursorPos(xPos+12, yPos+7) | |
1015 | mon.write("Limited:") | |
1016 | mon.setCursorPos(xPos+12, yPos+8) | |
1017 | if limitTransfer == true then | |
1018 | mon.setTextColor(colors.lime) | |
1019 | mon.write("On") | |
1020 | else | |
1021 | mon.setTextColor(colors.red) | |
1022 | mon.write("Off") | |
1023 | end | |
1024 | mon.setTextColor(colors.white) | |
1025 | end | |
1026 | ||
1027 | local function drawAll() | |
1028 | while true do | |
1029 | mon.clear() | |
1030 | versionText = "Version "..version.." by Game4Freak" | |
1031 | verPos = 51 - string.len(versionText) | |
1032 | mon.setCursorPos(verPos,26) | |
1033 | mon.setTextColor(colors.gray) | |
1034 | mon.write(versionText) | |
1035 | mon.setTextColor(colors.white) | |
1036 | drawBox(2,20,2,14,"ENERGY CORE") | |
1037 | drawBox(22,49,2,14,"DETAILS") | |
1038 | drawBox(2,24,16,25,"LOGS") | |
1039 | drawBox(26,49,16,25,"CONTROLS") | |
1040 | yPos = 4 | |
1041 | xMin = 5 | |
1042 | for xPos = xMin, xMin+12, 1 do | |
1043 | drawDetails(24,4) | |
1044 | drawControls(26,16) | |
1045 | getLogs("logs.cfg",2,16) | |
1046 | if tier <= 7 then | |
1047 | colorShield = colors.lightBlue | |
1048 | colorCore = colors.cyan | |
1049 | else | |
1050 | colorShield = colors.yellow | |
1051 | colorCore = colors.orange | |
1052 | end | |
1053 | xPos1 = xPos | |
1054 | if xPos1 >= xMin+13 then | |
1055 | xPos1a = xPos1 - 13 | |
1056 | drawL1(xPos1a, yPos) | |
1057 | else | |
1058 | drawL1(xPos1, yPos) | |
1059 | end | |
1060 | xPos2 = xPos + 1 | |
1061 | if xPos2 >= xMin+13 then | |
1062 | xPos2a = xPos2 - 13 | |
1063 | drawL2(xPos2a, yPos) | |
1064 | else | |
1065 | drawL2(xPos2, yPos) | |
1066 | end | |
1067 | xPos3 = xPos + 2 | |
1068 | if xPos3 >= xMin+13 then | |
1069 | xPos3a = xPos3 - 13 | |
1070 | drawL3(xPos3a, yPos) | |
1071 | else | |
1072 | drawL3(xPos3, yPos) | |
1073 | end | |
1074 | xPos4 = xPos + 3 | |
1075 | if xPos4 >= xMin+13 then | |
1076 | xPos4a = xPos4 - 13 | |
1077 | drawL4(xPos4a, yPos) | |
1078 | else | |
1079 | drawL4(xPos4, yPos) | |
1080 | end | |
1081 | xPos5 = xPos + 4 | |
1082 | if xPos5 >= xMin+13 then | |
1083 | xPos5a = xPos5 - 13 | |
1084 | drawL5(xPos5a, yPos) | |
1085 | else | |
1086 | drawL5(xPos5, yPos) | |
1087 | end | |
1088 | xPos6 = xPos + 5 | |
1089 | if xPos6 >= xMin+13 then | |
1090 | xPos6a = xPos6 - 13 | |
1091 | drawL6(xPos6a, yPos) | |
1092 | else | |
1093 | drawL6(xPos6, yPos) | |
1094 | end | |
1095 | xPos7 = xPos + 6 | |
1096 | if xPos7 >= xMin+13 then | |
1097 | xPos7a = xPos7 - 13 | |
1098 | drawL7(xPos7a, yPos) | |
1099 | else | |
1100 | drawL7(xPos7, yPos) | |
1101 | end | |
1102 | xPos8 = xPos + 7 | |
1103 | if xPos8 >= xMin+13 then | |
1104 | xPos8a = xPos8 - 13 | |
1105 | drawL8(xPos8a, yPos) | |
1106 | else | |
1107 | drawL8(xPos8, yPos) | |
1108 | end | |
1109 | xPos9 = xPos + 8 | |
1110 | if xPos9 >= xMin+13 then | |
1111 | xPos9a = xPos9 - 13 | |
1112 | drawL9(xPos9a, yPos) | |
1113 | else | |
1114 | drawL9(xPos9, yPos) | |
1115 | end | |
1116 | xPos10 = xPos + 9 | |
1117 | if xPos10 >= xMin+13 then | |
1118 | xPos10a = xPos10 - 13 | |
1119 | drawL10(xPos10a, yPos) | |
1120 | else | |
1121 | drawL10(xPos10, yPos) | |
1122 | end | |
1123 | xPos11 = xPos + 10 | |
1124 | if xPos11 >= xMin+13 then | |
1125 | xPos11a = xPos11 - 13 | |
1126 | drawL11(xPos11a, yPos) | |
1127 | else | |
1128 | drawL11(xPos11, yPos) | |
1129 | end | |
1130 | xPos12 = xPos + 11 | |
1131 | if xPos12 >= xMin+13 then | |
1132 | xPos12a = xPos12 - 13 | |
1133 | drawL12(xPos12a, yPos) | |
1134 | else | |
1135 | drawL12(xPos12, yPos) | |
1136 | end | |
1137 | xPos13 = xPos + 12 | |
1138 | if xPos13 >= xMin+13 then | |
1139 | xPos13a = xPos13 - 13 | |
1140 | drawL13(xPos13a, yPos) | |
1141 | else | |
1142 | drawL13(xPos13, yPos) | |
1143 | end | |
1144 | mon.setBackgroundColor(colors.black) | |
1145 | mon.setCursorPos(xMin, yPos) | |
1146 | mon.write(" ") | |
1147 | mon.setCursorPos(xMin+10, yPos) | |
1148 | mon.write(" ") | |
1149 | mon.setCursorPos(xMin, yPos+1) | |
1150 | mon.write(" ") | |
1151 | mon.setCursorPos(xMin+12, yPos+1) | |
1152 | mon.write(" ") | |
1153 | mon.setCursorPos(xMin, yPos+7) | |
1154 | mon.write(" ") | |
1155 | mon.setCursorPos(xMin+12, yPos+7) | |
1156 | mon.write(" ") | |
1157 | mon.setCursorPos(xMin, yPos+8) | |
1158 | mon.write(" ") | |
1159 | mon.setCursorPos(xMin+10, yPos+8) | |
1160 | mon.write(" ") | |
1161 | sleep(1) | |
1162 | end | |
1163 | end | |
1164 | end | |
1165 | ||
1166 | local function clickListener() | |
1167 | event, side, xCPos, yCPos = os.pullEvent("monitor_touch") | |
1168 | if xCPos == 1 and yCPos == 1 then | |
1169 | mon.setCursorPos(1,1) | |
1170 | mon.write("Click!") | |
1171 | sleep(1) | |
1172 | mon.write(" ") | |
1173 | end | |
1174 | if currentControls == "main" then | |
1175 | if xCPos >= 28 and xCPos <= 35 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then | |
1176 | drawClear(27,48,17,24) | |
1177 | currentControls = "editInput" | |
1178 | elseif xCPos >= 39 and xCPos <= 47 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then | |
1179 | drawClear(27,48,17,24) | |
1180 | currentControls = "editOutput" | |
1181 | elseif xCPos >= 28 and xCPos <= 35 and yCPos >= 22 and yCPos <= 23 then | |
1182 | drawClear(27,48,17,24) | |
1183 | currentControls = "editConfig" | |
1184 | end | |
1185 | elseif currentControls == "editInput" or currentControls == "editOutput" then | |
1186 | if xCPos >= 28 and xCPos <= 30 and yCPos == 20 then | |
1187 | mon.setCursorPos(28,20) | |
1188 | mon.setBackgroundColor(colors.gray) | |
1189 | mon.write(" 1 ") | |
1190 | putLimit = putLimit .. "1" | |
1191 | sleep(0.2) | |
1192 | mon.setCursorPos(28,20) | |
1193 | mon.setBackgroundColor(colors.lightGray) | |
1194 | mon.write(" 1 ") | |
1195 | mon.setBackgroundColor(1,1) | |
1196 | mon.setBackgroundColor(colors.black) | |
1197 | mon.write(" ") | |
1198 | elseif xCPos >= 32 and xCPos <= 34 and yCPos == 20 then | |
1199 | mon.setCursorPos(32,20) | |
1200 | mon.setBackgroundColor(colors.gray) | |
1201 | mon.write(" 2 ") | |
1202 | putLimit = putLimit .. "2" | |
1203 | sleep(0.2) | |
1204 | mon.setCursorPos(32,20) | |
1205 | mon.setBackgroundColor(colors.lightGray) | |
1206 | mon.write(" 2 ") | |
1207 | mon.setBackgroundColor(1,1) | |
1208 | mon.setBackgroundColor(colors.black) | |
1209 | mon.write(" ") | |
1210 | mon.write(" ") | |
1211 | elseif xCPos >= 36 and xCPos <= 38 and yCPos == 20 then | |
1212 | mon.setCursorPos(36,20) | |
1213 | mon.setBackgroundColor(colors.gray) | |
1214 | mon.write(" 3 ") | |
1215 | putLimit = putLimit.."3" | |
1216 | sleep(0.2) | |
1217 | mon.setCursorPos(36,20) | |
1218 | mon.setBackgroundColor(colors.lightGray) | |
1219 | mon.write(" 3 ") | |
1220 | mon.setBackgroundColor(1,1) | |
1221 | mon.setBackgroundColor(colors.black) | |
1222 | mon.write(" ") | |
1223 | elseif xCPos >= 28 and xCPos <= 30 and yCPos == 21 then | |
1224 | mon.setCursorPos(28,21) | |
1225 | mon.setBackgroundColor(colors.gray) | |
1226 | mon.write(" 4 ") | |
1227 | putLimit = putLimit.."4" | |
1228 | sleep(0.2) | |
1229 | mon.setCursorPos(28,21) | |
1230 | mon.setBackgroundColor(colors.lightGray) | |
1231 | mon.write(" 4 ") | |
1232 | mon.setBackgroundColor(1,1) | |
1233 | mon.setBackgroundColor(colors.black) | |
1234 | mon.write(" ") | |
1235 | elseif xCPos >= 32 and xCPos <= 34 and yCPos == 21 then | |
1236 | mon.setCursorPos(32,21) | |
1237 | mon.setBackgroundColor(colors.gray) | |
1238 | mon.write(" 5 ") | |
1239 | putLimit = putLimit.."5" | |
1240 | sleep(0.2) | |
1241 | mon.setCursorPos(32,21) | |
1242 | mon.setBackgroundColor(colors.lightGray) | |
1243 | mon.write(" 5 ") | |
1244 | mon.setBackgroundColor(1,1) | |
1245 | mon.setBackgroundColor(colors.black) | |
1246 | mon.write(" ") | |
1247 | elseif xCPos >= 36 and xCPos <= 38 and yCPos == 21 then | |
1248 | mon.setCursorPos(36,21) | |
1249 | mon.setBackgroundColor(colors.gray) | |
1250 | mon.write(" 6 ") | |
1251 | putLimit = putLimit.."6" | |
1252 | sleep(0.2) | |
1253 | mon.setCursorPos(36,21) | |
1254 | mon.setBackgroundColor(colors.lightGray) | |
1255 | mon.write(" 6 ") | |
1256 | mon.setBackgroundColor(1,1) | |
1257 | mon.setBackgroundColor(colors.black) | |
1258 | mon.write(" ") | |
1259 | elseif xCPos >= 28 and xCPos <= 30 and yCPos == 22 then | |
1260 | mon.setCursorPos(28,22) | |
1261 | mon.setBackgroundColor(colors.gray) | |
1262 | mon.write(" 7 ") | |
1263 | putLimit = putLimit.."7" | |
1264 | sleep(0.2) | |
1265 | mon.setCursorPos(28,22) | |
1266 | mon.setBackgroundColor(colors.lightGray) | |
1267 | mon.write(" 7 ") | |
1268 | mon.setBackgroundColor(1,1) | |
1269 | mon.setBackgroundColor(colors.black) | |
1270 | mon.write(" ") | |
1271 | elseif xCPos >= 32 and xCPos <= 34 and yCPos == 22 then | |
1272 | mon.setCursorPos(32,22) | |
1273 | mon.setBackgroundColor(colors.gray) | |
1274 | mon.write(" 8 ") | |
1275 | putLimit = putLimit.."8" | |
1276 | sleep(0.2) | |
1277 | mon.setCursorPos(32,22) | |
1278 | mon.setBackgroundColor(colors.lightGray) | |
1279 | mon.write(" 8 ") | |
1280 | mon.setBackgroundColor(1,1) | |
1281 | mon.setBackgroundColor(colors.black) | |
1282 | mon.write(" ") | |
1283 | elseif xCPos >= 36 and xCPos <= 38 and yCPos == 22 then | |
1284 | mon.setCursorPos(36,22) | |
1285 | mon.setBackgroundColor(colors.gray) | |
1286 | mon.write(" 9 ") | |
1287 | putLimit = putLimit.."9" | |
1288 | sleep(0.2) | |
1289 | mon.setCursorPos(36,22) | |
1290 | mon.setBackgroundColor(colors.lightGray) | |
1291 | mon.write(" 9 ") | |
1292 | mon.setBackgroundColor(1,1) | |
1293 | mon.setBackgroundColor(colors.black) | |
1294 | mon.write(" ") | |
1295 | elseif xCPos >= 28 and xCPos <= 30 and yCPos == 23 then | |
1296 | mon.setCursorPos(28,23) | |
1297 | mon.setBackgroundColor(colors.gray) | |
1298 | mon.write(" < ") | |
1299 | putLimit = string.sub(putLimit,0,string.len(putLimit)-1) | |
1300 | sleep(0.2) | |
1301 | mon.setCursorPos(28,23) | |
1302 | mon.setBackgroundColor(colors.red) | |
1303 | mon.write(" < ") | |
1304 | mon.setBackgroundColor(1,1) | |
1305 | mon.setBackgroundColor(colors.black) | |
1306 | mon.write(" ") | |
1307 | elseif xCPos >= 32 and xCPos <= 34 and yCPos == 23 then | |
1308 | mon.setCursorPos(32,23) | |
1309 | mon.setBackgroundColor(colors.gray) | |
1310 | mon.write(" 0 ") | |
1311 | putLimit = putLimit.."0" | |
1312 | sleep(0.2) | |
1313 | mon.setCursorPos(32,23) | |
1314 | mon.setBackgroundColor(colors.lightGray) | |
1315 | mon.write(" 0 ") | |
1316 | mon.setBackgroundColor(1,1) | |
1317 | mon.setBackgroundColor(colors.black) | |
1318 | mon.write(" ") | |
1319 | elseif xCPos >= 36 and xCPos <= 38 and yCPos == 23 then | |
1320 | mon.setCursorPos(36,23) | |
1321 | mon.setBackgroundColor(colors.gray) | |
1322 | mon.write(" X ") | |
1323 | putLimit = "" | |
1324 | sleep(0.2) | |
1325 | mon.setCursorPos(36,23) | |
1326 | mon.setBackgroundColor(colors.red) | |
1327 | mon.write(" X ") | |
1328 | mon.setBackgroundColor(1,1) | |
1329 | mon.setBackgroundColor(colors.black) | |
1330 | mon.write(" ") | |
1331 | elseif xCPos >= 42 and xCPos <= 47 and yCPos == 23 then | |
1332 | putLimit = "" | |
1333 | drawClear(27,48,17,24) | |
1334 | currentControls = "main" | |
1335 | elseif xCPos >= 42 and xCPos <= 47 and yCPos == 21 then | |
1336 | if currentControls == "editInput" then | |
1337 | if putLimit == "" then | |
1338 | putLimitNum = 0 | |
1339 | else | |
1340 | putLimitNum = tonumber(putLimit) | |
1341 | end | |
1342 | input.setSignalLowFlow(putLimitNum) | |
1343 | addLog("logs.cfg",getTime(false),"InputMax > "..convertRF(putLimitNum)) | |
1344 | else | |
1345 | if putLimit == "" then | |
1346 | putLimitNum = 0 | |
1347 | else | |
1348 | putLimitNum = tonumber(putLimit) | |
1349 | end | |
1350 | output.setSignalLowFlow(putLimitNum) | |
1351 | addLog("logs.cfg",getTime(false),"OutputMax > "..convertRF(putLimitNum)) | |
1352 | end | |
1353 | putLimit = "" | |
1354 | drawClear(27,48,17,24) | |
1355 | currentControls = "main" | |
1356 | end | |
1357 | elseif currentControls == "editConfig" then | |
1358 | if xCPos >= 28 and xCPos <= 28+8 and yCPos >= 18 and yCPos <= 19 and limitTransfer == true then | |
1359 | drawButton(26+2,26+10,16+3,16+4,"Detect","Flux_Gate",colors.gray) | |
1360 | detectInOutput() | |
1361 | addLog("logs.cfg",getTime(false),"Detected Flux_Gates") | |
1362 | elseif xCPos >= 26+16 and xCPos <= 26+16+6 and yCPos >= 16+7 and yCPos <= 16+7 then | |
1363 | currentControls = "main" | |
1364 | elseif xCPos >= 40 and xCPos <= 47 and yCPos >= 19 and yCPos <= 20 then | |
1365 | currentControls = "editTimezone" | |
1366 | end | |
1367 | elseif currentControls == "editTimezone" then | |
1368 | if xCPos >= 26+9 and xCPos <= 26+15 and yCPos >= 16+7 and yCPos <= 16+7 then | |
1369 | currentControls = "main" | |
1370 | elseif xCPos >= 26+16 and xCPos <= 26+16+6 and yCPos >= 16+7 and yCPos <= 16+7 then | |
1371 | if timediff >= -12 and timediff <= 12 then | |
1372 | editConfigFile("config.cfg",1,"Timezone: "..timediff) | |
1373 | elseif timediff < -12 then | |
1374 | editConfigFile("config.cfg",1,"Timezone: -12") | |
1375 | elseif timediff > 12 then | |
1376 | editConfigFile("config.cfg",1,"Timezone: 12") | |
1377 | end | |
1378 | addLog("logs.cfg",getTime(false),"Edited Timezone") | |
1379 | currentControls = "main" | |
1380 | elseif xCPos >= 26+2+3 and xCPos <= 26+2+4+2 and yCPos >= 16+4 and yCPos <= 16+4 then | |
1381 | timediff = timediff-1 | |
1382 | elseif xCPos >= 26+2+4+8 and xCPos <= 26+2+4+6+5 and yCPos >= 16+4 and yCPos <= 16+4 then | |
1383 | timediff = timediff+1 | |
1384 | end | |
1385 | end | |
1386 | end | |
1387 | ||
1388 | while true do | |
1389 | parallel.waitForAny(drawAll,clickListener) | |
1390 | end |