Advertisement
Guest User

Untitled

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