theo33500

Untitled

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