Advertisement
Guest User

stian

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