Hiratlas0

Untitled

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