Hiratlas0

CC:tweaked X Draconic Evolution Energy Core Monitoring System

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