bobmarley12345

Untitled

Sep 14th, 2021 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.27 KB | None | 0 0
  1. function string.jsub(str, startIndex, endIndex)
  2. if (endIndex == nil) then
  3. endIndex = string.len(str) + 1
  4. end
  5.  
  6. return string.sub(str, startIndex, endIndex - 1)
  7. end
  8.  
  9. -- Checks if the given `str` starts with the given `value` (optionally start searching with the given start offset index. 1 by default). `string.startsWith("hello", "he", 1)` == `true`
  10. function string.startsWith(str, value, startIndex)
  11. if (startIndex == nil) then
  12. startIndex = 1
  13. end
  14.  
  15. return string.jsub(str, startIndex, string.len(value) + startIndex) == value
  16. end
  17.  
  18. -- Checks if the given `str` ends with the given value. string.endsWith("hello", "lo") == true
  19. function string.endsWith(str, value)
  20. local strLen = string.len(str)
  21. local valLen = string.len(value)
  22. return string.sub(str, strLen - valLen + 1, strLen) == value
  23. end
  24.  
  25. function string.contains(str, value, startIndex)
  26. if (startIndex == nil) then
  27. startIndex = 1
  28. end
  29.  
  30. return string.find(str, value) ~= nil
  31. end
  32.  
  33. function string.indexOf(str, value, startIndex)
  34. if (startIndex == nil) then
  35. startIndex = 1
  36. end
  37.  
  38. local s,e,c = string.find(str, value)
  39. if (s == nil) then
  40. return -1
  41. end
  42.  
  43. return s
  44. end
  45.  
  46. -- Clamps the given string to the given length. `string.len(str)` is smaller than or equal to `maxLen` then `str` is returned. Otherwise, a substring of `maxLen - 3` of characters + `"..."` is returned
  47. function string.clampString(str, maxLen)
  48. local strLen = string.len(str)
  49. if (strLen <= maxLen) then
  50. return str
  51. end
  52.  
  53. return (string.sub(str, 1, maxLen - 3) .. "...")
  54. end
  55.  
  56. utils = { }
  57.  
  58. -- Calculates the center Y coordinate between `start` (inclusive) and `end` (inclusive)
  59. function utils.centerOf(start, ending)
  60. if (start == ending) then
  61. return start
  62. elseif (start < ending) then
  63. return math.floor((ending - start) / 2)
  64. else
  65. return math.floor((start - ending) / 2)
  66. end
  67. end
  68.  
  69. function utils.thatOrNull(nullable, nonNull)
  70. if (nullable == nil) then
  71. return nonNull
  72. end
  73.  
  74. return nullable
  75. end
  76.  
  77. function utils.byteToMegaByte(bytes)
  78. return bytes / 1048576
  79. end
  80.  
  81. function utils.byteToKiloByte(bytes)
  82. return bytes / 1024
  83. end
  84.  
  85. function utils.byteToGigaByte(bytes)
  86. return bytes / 1073741824
  87. end
  88.  
  89. GDI = {
  90. Handle = { }
  91. }
  92.  
  93. -- returns a non null text colour
  94. function GDI.nonNullTextColour(text_colour)
  95. if (text_colour == nil) then
  96. return colours.white
  97. end
  98.  
  99. return text_colour
  100. end
  101.  
  102. -- returns a non null background colour
  103. function GDI.nonNullBackgroundColour(background_colour)
  104. if (background_colour == nil) then
  105. return colours.black
  106. end
  107.  
  108. return background_colour
  109. end
  110.  
  111. -- sets the monitor cursor pos
  112. function GDI.cpos(x, y)
  113. GDI.Handle.setCursorPos(x, y)
  114. end
  115.  
  116. -- sets the monitor text colour
  117. function GDI.textColour(colour)
  118. GDI.Handle.setTextColor(colour)
  119. end
  120.  
  121. -- sets the monitor background colour
  122. function GDI.backgroundColour(colour)
  123. GDI.Handle.setBackgroundColor(colour)
  124. end
  125.  
  126. function GDI.clearBackground(foreground, background)
  127. GDI.textColour(GDI.nonNullTextColour(foreground))
  128. GDI.backgroundColour(GDI.nonNullBackgroundColour(background))
  129. GDI.Handle.clear()
  130. end
  131.  
  132. -- draws text on the monitor
  133. function GDI.drawText(x, y, text, foreground, background)
  134. GDI.textColour(GDI.nonNullTextColour(foreground))
  135. GDI.backgroundColour(GDI.nonNullBackgroundColour(background))
  136. GDI.cpos(x, y)
  137. local txt = tostring(text)
  138. GDI.Handle.write(txt)
  139. return string.len(txt)
  140. end
  141.  
  142. -- function GDI.drawLineH(x, y, w, background)
  143. -- GDI.drawText(x, y, string.rep(" ", w), background, background)
  144. -- end
  145. --
  146. -- function GDI.drawLineV(x, y, h, background)
  147. -- GDI.textColour(GDI.nonNullTextColour(background))
  148. -- GDI.backgroundColour(GDI.nonNullBackgroundColour(background))
  149. -- for i = y, h do
  150. -- GDI.Handle.write(" ")
  151. -- GDI.cpos(x, i)
  152. -- end
  153. -- end
  154. --
  155. -- function GDI.drawSquare(x, y, w, h, background)
  156. -- local line = y
  157. -- local endLine = y + h
  158. -- while (true) do
  159. -- GDI.drawLineH(x, line, w, background)
  160. -- line = line + 1
  161. -- if (line >= endLine) then
  162. -- return
  163. -- end
  164. -- end
  165. -- end
  166. --
  167.  
  168. function GDI.drawLineH(x, y, w, background)
  169. term.redirect(GDI.Handle)
  170. paintutils.drawLine(x, y, x + w, y, background)
  171. term.redirect(term)
  172. -- GDI.drawText(x, y, string.rep(" ", w), background, background)
  173. end
  174.  
  175. function GDI.drawLineV(x, y, h, background)
  176. term.redirect(GDI.Handle)
  177. paintutils.drawLine(x, y, x, y + h, background)
  178. term.redirect(term)
  179. -- GDI.textColour(GDI.nonNullTextColour(background))
  180. -- GDI.backgroundColour(GDI.nonNullBackgroundColour(background))
  181. -- for i = y, h do
  182. -- GDI.Handle.write(" ")
  183. -- GDI.cpos(x, i)
  184. -- end
  185. end
  186.  
  187. function GDI.drawSquare(x, y, w, h, background)
  188. term.redirect(GDI.Handle)
  189. paintutils.drawLine(x, y, x + w, y + h, background)
  190. term.redirect(term)
  191. -- local line = y
  192. -- local endLine = y + h
  193. -- while (true) do
  194. -- GDI.drawLineH(x, line, w, background)
  195. -- line = line + 1
  196. -- if (line >= endLine) then
  197. -- return
  198. -- end
  199. -- end
  200. end
  201.  
  202. function GDI.drawProgressBar(x, y, w, h, min, max, val, foreground, background)
  203. GDI.drawSquare(x, y, w, h, background)
  204. GDI.drawSquare(x, y, math.floor((val / (max - min)) * w), h, foreground)
  205. end
  206.  
  207. -- hello 5
  208. -- helo- 4
  209. -- -hie- 3
  210. -- -hi-- 2
  211. -- - h - 1
  212.  
  213. -- - h -- 1
  214.  
  215. -- - hh -- 2
  216. -- -- h -- 1
  217.  
  218. function GDI.drawGroupBoxHeader(x, y, w, text, foreground, background)
  219. local strLen = string.len(text)
  220. if (strLen >= w) then
  221. GDI.drawText(x, y, string.sub(text, 1, w), foreground, background)
  222. elseif (strLen == (w - 1)) then
  223. GDI.drawText(x, y, text .. "-", foreground, background)
  224. elseif (strLen == (w - 2)) then
  225. GDI.drawText(x, y, "-" .. text .. "-", foreground, background)
  226. elseif (strLen == (w - 3)) then
  227. GDI.drawText(x, y, "-" .. text .. " -", foreground, background)
  228. else
  229. local leftOverSpace = strLen - w
  230. local halfLeftOver = leftOverSpace / 2
  231. if (leftOverSpace % 2 == 0) then -- even
  232. local glyphText = string.rep("-", halfLeftOver - 1)
  233. GDI.drawText(x, y, glyphText .. " " .. text .. " " .. glyphText)
  234. else -- odd
  235. local glyphTextA = string.rep("-", math.floor(halfLeftOver - 1))
  236. local glyphTextB = string.rep("-", math.ceil(halfLeftOver - 1))
  237. GDI.drawText(x, y, glyphTextA .. " " .. text .. " " .. glyphTextB)
  238. end
  239. end
  240. end
  241.  
  242. function GDI.drawGroupBoxWall(x, y, h, foreground, background)
  243. GDI.textColour(GDI.nonNullTextColour(foreground))
  244. GDI.backgroundColour(GDI.nonNullBackgroundColour(background))
  245. for i = y, h do
  246. GDI.Handle.write("-")
  247. GDI.cpos(x, i)
  248. end
  249. end
  250.  
  251. function GDI.drawGroupBoxFooter(x, y, w, foreground, background)
  252. GDI.drawText(x, y, string.rep("-", w), foreground, background)
  253. end
  254.  
  255. function GDI.drawGroupBox(x, y, w, h, header, border_foreground, border_background, background)
  256. GDI.drawSquare(x, y, w, h, background)
  257. GDI.drawGroupBoxHeader(x, y, w, header, border_foreground, border_background)
  258. GDI.drawGroupBoxWall(x, y, h, border_foreground, border_background)
  259. GDI.drawGroupBoxWall(x + w, y, h, border_foreground, border_background)
  260. GDI.drawGroupBoxFooter(x, y + h, w, border_foreground, border_background)
  261. end
  262.  
  263. function GDI.drawWindowTitle(x, y, w, title, foreground, background)
  264. if (background == nil) then
  265. background = colours.grey
  266. end
  267. local len = GDI.drawText(x, y, string.clampString(title, w - 5), foreground, background)
  268. local endX = x + w
  269. GDI.drawLineH(x + len, y, w - len - 4, background)
  270. GDI.drawText(endX - 4, y, "-", colours.foreground, colours.lightGrey)
  271. GDI.drawText(endX - 3, y, "[]", colours.foreground, colours.lightGrey)
  272. GDI.drawText(endX - 1, y, "x", colours.foreground, colours.red)
  273. end
  274.  
  275. function GDI.drawWindow(x, y, w, h, title, titleForeground, titleBackground, background)
  276. GDI.drawSquare(x, y, w, h, utils.thatOrNull(background, colours.white))
  277. GDI.drawWindowTitle(x, y, w, title, utils.thatOrNull(titleForeground, colours.lightGrey), utils.thatOrNull(titleBackground, colours.grey))
  278. end
  279.  
  280. function GDI.clearMonitor()
  281. GDI.textColour(colours.white)
  282. GDI.backgroundColour(colours.black)
  283. GDI.Handle.clear()
  284. end
  285.  
  286. totalMinEnergy = 0
  287. totalMaxEnergy = 0
  288. totalStoredEnergy = 0
  289. biggestId = 0
  290. peripherals = { }
  291. line = 1
  292.  
  293. function getTypeAndId(name)
  294. local nameIndex = string.indexOf(name, "_name")
  295. if (nameIndex == -1) then
  296. return nil
  297. end
  298.  
  299. local machineId = tonumber(string.sub(name, nameIndex + 5))
  300. if (machineId == nil) then
  301. return nil
  302. end
  303.  
  304. return string.sub(name, 31, nameIndex - 1), machineId
  305. end
  306.  
  307. Monitors = {
  308. Peripherals = {
  309.  
  310. },
  311. Information = {
  312. Setup = function (me)
  313. -- local w,h = me.Handle.getSize()
  314. -- me.Width = w
  315. -- me.Height = h
  316. -- 25
  317. me.Handle.setTextScale(1)
  318.  
  319. -- tile_thermalexpansion_machine_pulverizer_name_<number> = pulverizer
  320. -- tile_thermalexpansion_machine_smelter_name_<number> = induction
  321. -- tile_thermalexpansion_machine_furnace_name_<number> = furnace
  322.  
  323. for i, name in pairs(peripheral.getNames()) do
  324. if (name ~= nil) then
  325. if (string.startsWith(name, "tile_thermalexpansion_machine_", 1)) then
  326. local name, id = getTypeAndId(name)
  327. if (name ~= nil and id ~= nil) then
  328. local cellHandle = peripheral.wrap(name)
  329. me.Peripherals[id] = {
  330. Handle = cellHandle,
  331. DeviceFullName = name,
  332. DeviceMinEnergy = 0,
  333. DeviceMaxEnergy = 0,
  334. DeviceEnergyStored = 0,
  335. CellID = id
  336. }
  337. end
  338. end
  339. end
  340. end
  341.  
  342. end,
  343. Handle = peripheral.wrap("monitor_51"),
  344. Width = 82,
  345. Height = 33,
  346. IsInteractive = true,
  347. Update = function (me)
  348.  
  349. end,
  350. Draw = function (me)
  351.  
  352. end
  353. },
  354. PlayerInfo = {
  355. Setup = function (me)
  356. end,
  357. Handle = peripheral.wrap("monitor_56"),
  358. Width = 18,
  359. Height = 33,
  360. IsInteractive = false,
  361. Update = function (me)
  362.  
  363. end,
  364. Draw = function (me)
  365.  
  366. end
  367. },
  368. PowerInfo = {
  369. Setup = function (me)
  370. GDI.drawSquare(1, 1, 7, me.Height, colours.grey)
  371. GDI.drawSquare(1, me.Height - 3, me.Width, 4, colours.grey)
  372. end,
  373. Handle = peripheral.wrap("monitor_53"),
  374. Width = 29,
  375. Height = 40,
  376. IsInteractive = false,
  377. StartMaxIdLen = 1,
  378. TotalCellMin = 0,
  379. TotalCellMax = 0,
  380. TotalCellStored = 0,
  381. Cells = {
  382. Cell1 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_0"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell1.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell1.Handle.getEnergyStored("UNKNOWN") end },
  383. Cell2 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_1"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell2.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell2.Handle.getEnergyStored("UNKNOWN") end },
  384. Cell3 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_2"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell3.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell3.Handle.getEnergyStored("UNKNOWN") end },
  385. Cell4 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_3"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell4.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell4.Handle.getEnergyStored("UNKNOWN") end },
  386. Cell5 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_4"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell5.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell5.Handle.getEnergyStored("UNKNOWN") end },
  387. Cell6 = { Handle = peripheral.wrap("cofh_thermalexpansion_energycell_5"), Min = function() return 0 end, Max = function () return Monitors.PowerInfo.Cells.Cell6.Handle.getMaxEnergyStored("UNKNOWN") end, Stored = function () return Monitors.PowerInfo.Cells.Cell6.Handle.getEnergyStored("UNKNOWN") end }
  388. },
  389. LineIndex = 1,
  390. Update = function (me)
  391.  
  392. end,
  393. Draw = function (me)
  394. local line = 2
  395. for k,v in pairs(me.Cells) do
  396. me.LocalFunctions.drawEnergyCell(me, line, v, tostring(k))
  397. line = line + 2
  398. end
  399. GDI.drawText(2, me.Height - 2, "Total energy", colours.white, colours.grey)
  400. GDI.drawProgressBar(2, me.Height - 1, me.Width - 2, 1, me.TotalCellMin, me.TotalCellMax, me.TotalCellStored, colours.cyan, colours.grey)
  401. end,
  402. LocalFunctions = {
  403. drawEnergyCell = function (me, y, cell, name)
  404. GDI.drawText(2, y, name, colours.white, colours.grey)
  405. local startX = string.len(name) + 4
  406. local min = cell.Min()
  407. local max = cell.Max()
  408. local val = cell.Stored()
  409. me.TotalCellMin = me.TotalCellMin + min
  410. me.TotalCellMax = me.TotalCellMax + max
  411. me.TotalCellStored = me.TotalCellStored + val
  412. GDI.drawProgressBar(startX, y, me.Width - startX, 1, min, max, val, colours.cyan, colours.grey)
  413. end
  414. }
  415. },
  416. InteractiveMain = {
  417. Setup = function (me)
  418. GDI.drawSquare(4, 15, 35, 11, colours.white)
  419. me.LoadCells()
  420. end,
  421. LoadCells = function()
  422. for i, name in pairs(peripheral.getNames()) do
  423. if (string.startsWith(name, "cofh_thermalexpansion_energycell_", 1)) then
  424. local cellId = tonumber(string.sub(tostring(name), 34))
  425. if (cellId ~= nil) then
  426. if (cellId > biggestId) then
  427. biggestId = cellId
  428. end
  429. local cellHandle = peripheral.wrap(name)
  430. peripherals[cellId] = {
  431. Handle = cellHandle,
  432. full_name = name,
  433. minEnergy = 0,
  434. maxEnergy = 0,
  435. stored = 0,
  436. id = cellId,
  437. update = function (cell_id)
  438. local cell = peripherals[cell_id]
  439. if (cell.Handle ~= nil) then
  440. cell.minEnergy = 0
  441. cell.maxEnergy = cell.Handle.getMaxEnergyStored("UNKNOWN")
  442. cell.stored = cell.Handle.getEnergyStored("UNKNOWN")
  443. end
  444. end
  445. }
  446. end
  447. end
  448. end
  449. end,
  450. LineNumber = 1,
  451. DrawCell = function (me, x, y, w, h, name, cell)
  452. local offset = string.len(tostring(biggestId))
  453. local startX = x + offset
  454. GDI.drawText(x + 1, y, name, colours.black, colours.white)
  455. GDI.drawProgressBar(startX + 3, y, w - offset - 4, 1, cell.minEnergy, cell.maxEnergy, cell.stored, colours.cyan, colours.lightGrey)
  456. end,
  457. TotalCellCount = 0,
  458. StaticCellCount = 0,
  459. Handle = peripheral.wrap("monitor_54"),
  460. Width = 71,
  461. Height = 26,
  462. IsInteractive = true,
  463. MESystem = {
  464. Handle = peripheral.wrap("appeng_me_tilecontroller_1"),
  465. GetTotalBytes = function () return Monitors.InteractiveMain.MESystem.Handle.getTotalBytes() end,
  466. GetFreeBytes = function () return Monitors.InteractiveMain.MESystem.Handle.getFreeBytes() end,
  467. GetUsedBytes = function () return Monitors.InteractiveMain.MESystem.Handle.getTotalBytes() - Monitors.InteractiveMain.MESystem.Handle.getFreeBytes() end
  468. },
  469. Update = function (me)
  470. TotalCellCount = 0
  471. for k,v in pairs(peripherals) do
  472. v.update(k)
  473. TotalCellCount = TotalCellCount + 1
  474. end
  475.  
  476. if (me.StaticCellCount ~= me.TotalCellCount) then
  477. me.StaticCellCount = me.TotalCellCount
  478. me.Draw(me)
  479. end
  480. end,
  481. Draw = function (me)
  482. GDI.drawWindowTitle(4, 15, 35, "ME System Storage Monitor", colours.lightGrey, colours.grey)
  483. me.LocalFunctions.DrawMEPowerMon(me, 4, 16, 35, 11)
  484. local h = (TotalCellCount * 2) + 2
  485. GDI.drawWindow(40, 3, 24, h, "dynamic cells")
  486. local line = 2
  487. for k,v in pairs(peripherals) do
  488. me.DrawCell(me, 40, line + 3, 24, h, k, v)
  489. line = line + 2
  490. end
  491. end,
  492. LocalFunctions = {
  493. DrawMEPowerMon = function (me, x, y, w, h)
  494. local bytesTotal = me.MESystem.GetTotalBytes()
  495. local bytesFree = me.MESystem.GetFreeBytes()
  496. local bytesUsed = bytesTotal - bytesFree
  497. GDI.drawText(x + 1, y + 1, "Total Bytes", colours.black, colours.white)
  498. GDI.drawText(x + 1, y + 2, utils.byteToMegaByte(bytesTotal) .. " MB", colours.black, colours.white)
  499. GDI.drawText(x + 1, y + 4, "Free Bytes", colours.black, colours.white)
  500. GDI.drawText(x + 1, y + 5, utils.byteToMegaByte(bytesFree) .. " MB", colours.black, colours.white)
  501. GDI.drawText(x + 1, y + 7, "Bytes in Use", colours.black, colours.white)
  502. GDI.drawProgressBar(x + 1, y + 8, w - 2, 1, 0, bytesTotal, bytesUsed, colours.green, colours.grey)
  503. end
  504. }
  505. },
  506. NewsBoard = {
  507. Setup = function (me)
  508. local strLen = string.len(me.Text)
  509. me.StartOffset = 1 - strLen
  510. me.EndOffset = strLen
  511. end,
  512. Handle = peripheral.wrap("monitor_55"),
  513. Width = 71,
  514. Height = 5,
  515. Text = "ello ello ello this is the police",
  516. Offset = 1,
  517. StartOffset = 1,
  518. EndOffset = 1,
  519. IsInteractive = false,
  520. Update = function (me)
  521. if (me.Offset >= me.EndOffset) then
  522. me.Offset = me.StartOffset
  523. else
  524. me.Offset = me.Offset + 1
  525. end
  526. end,
  527. Draw = function (me)
  528. GDI.clearMonitor()
  529. GDI.drawText(me.Offset, 3, me.Text, colours.white, colours.grey)
  530. end
  531. }
  532. }
  533.  
  534. function loadMonitor(mon)
  535. GDI.Handle = mon.Handle
  536. end
  537.  
  538. function ProcessMonitor(mon)
  539. loadMonitor(mon)
  540. mon.Update(mon)
  541. mon.Draw(mon)
  542. end
  543.  
  544. function ClearMonitor()
  545. GDI.backgroundColour(GDI.nonNullBackgroundColour(nil))
  546. GDI.textColour(GDI.nonNullTextColour(nil))
  547. GDI.Handle.clear()
  548. end
  549.  
  550. function tryExec(func)
  551. pcall(func)
  552. end
  553.  
  554. function UpdateMonitors()
  555. ProcessMonitor(Monitors.Information)
  556. ProcessMonitor(Monitors.InteractiveMain)
  557. ProcessMonitor(Monitors.NewsBoard)
  558. ProcessMonitor(Monitors.PlayerInfo)
  559. ProcessMonitor(Monitors.PowerInfo)
  560. end
  561.  
  562. function main()
  563. loadMonitor(Monitors.Information)
  564. ClearMonitor()
  565. loadMonitor(Monitors.InteractiveMain)
  566. ClearMonitor()
  567. loadMonitor(Monitors.NewsBoard)
  568. ClearMonitor()
  569. loadMonitor(Monitors.PlayerInfo)
  570. ClearMonitor()
  571. loadMonitor(Monitors.PowerInfo)
  572. ClearMonitor()
  573.  
  574. loadMonitor(Monitors.Information)
  575. Monitors.Information.Setup(Monitors.Information)
  576. loadMonitor(Monitors.InteractiveMain)
  577. Monitors.InteractiveMain.Setup(Monitors.InteractiveMain)
  578. loadMonitor(Monitors.NewsBoard)
  579. Monitors.NewsBoard.Setup(Monitors.NewsBoard)
  580. loadMonitor(Monitors.PlayerInfo)
  581. Monitors.PlayerInfo.Setup(Monitors.PlayerInfo)
  582. loadMonitor(Monitors.PowerInfo)
  583. Monitors.PowerInfo.Setup(Monitors.PowerInfo)
  584. while (true) do
  585. tryExec(UpdateMonitors)
  586. os.sleep(0.2)
  587.  
  588. if (rs.getBundledInput("bottom") == colours.white) then
  589. return
  590. elseif (rs.getBundledInput("bottom") == colours.orange) then
  591. os.reboot()
  592. end
  593. end
  594. end
  595.  
  596. main()
  597.  
  598. print("Exit button clicked!")
Add Comment
Please, Sign In to add comment