BeefyMuscle

Beef's Matrix Monitor

Oct 19th, 2024 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.45 KB | Gaming | 0 0
  1. --Beef's Matrix Monitor--
  2.  
  3.  
  4. m = peripheral.find("monitor")
  5.  
  6.  
  7. im = peripheral.find("Induction Matrix")
  8.  
  9.  
  10. m.clear()
  11.  
  12.  
  13. --Setting Universal Variables--
  14.  
  15. monX, monY = m.getSize()
  16. local mult = 10^2
  17. local center = math.floor(monX/2)
  18.  
  19. --Core Program Loop--
  20. while (true)
  21.     do
  22.  
  23.         --get power levels--
  24.  
  25.         maxPow = im.getMaxEnergy()
  26.         curPow = im.getEnergy()
  27.         curIn = im.getInput()
  28.         curOut = im.getOutput()
  29.         tfCap = im.getTransferCap()
  30.         charge = math.floor(curPow / maxPow * 100 + 0.5)
  31.         tUse = math.floor((curIn+curOut)/tfCap * 100 + 0.5)
  32.  
  33.  
  34.  
  35.         --Draw Labels--
  36.  
  37.         m.clear()
  38.         m.setTextScale(.9)
  39.         m.setBackgroundColor(colors.black)
  40.         m.setTextColor(colors.orange)
  41.         m.setCursorPos(center-7,6)
  42.         m.write("Induction Matrix")
  43.  
  44.         m.setCursorPos(center-43,11)
  45.         m.write("Max Power")
  46.         m.setCursorPos(center-45,15)
  47.         m.write("Current Power")
  48.         m.setCursorPos(center-41,19)
  49.         m.write("Input")
  50.         m.setCursorPos(center-41,23)
  51.         m.write("Output")
  52.         m.setCursorPos(center-44,27)
  53.         m.write("Transfer Cap")
  54.  
  55.  
  56.         m.setBackgroundColor(colors.orange)
  57.         m.setCursorPos(2,2)
  58.         m.write(string.rep(" ", (monX)-2))
  59.         m.setCursorPos(2,37)
  60.         m.write(string.rep(" ", (monX)-2))
  61.        
  62.         m.setBackgroundColor(colors.black)
  63.  
  64.  
  65.         --Write Max Power--
  66.  
  67.         m.setTextColor(colors.white)
  68.         m.setCursorPos(center-42, 13)
  69.         e = im.getMaxEnergy()
  70.         if e >= 1000 and e < 1000000  then
  71.             m.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
  72.             m.write("kRF")
  73.         elseif e >= 1000000 and e < 1000000000  then
  74.             m.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
  75.             m.write("mRF")
  76.         elseif e >= 1000000000 and e < 1000000000000  then
  77.             m.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
  78.             m.write("gRF")
  79.         else
  80.             m.write(tostring(im.maxPow))
  81.             m.write("RF")
  82.         end
  83.  
  84.  
  85.          -- Write Current Power--
  86.  
  87.         m.setCursorPos(center-42, 17)
  88.         e = im.getEnergy()
  89.         if e >= 1000 and e < 1000000  then
  90.             m.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
  91.             m.write("kRF")
  92.         elseif e >= 1000000 and e < 1000000000  then
  93.             m.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
  94.             m.write("mRF")
  95.         elseif e >= 1000000000 and e < 1000000000000  then
  96.             m.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
  97.             m.write("gRF")
  98.         else
  99.             m.write(tostring(curPow))
  100.             m.write("RF")
  101.         end      
  102.        
  103.        
  104.         --Write Input RF--
  105.  
  106.         m.setCursorPos(center-42, 21)
  107.         InputOut = 0
  108.         e = im.getInput()
  109.         if e >= 1000 and e < 1000000  then
  110.             m.write(tostring(math.floor(e/1000 * mult + 0.5)/mult))
  111.             m.write("kRF/t")
  112.         elseif e >= 1000000 and e < 1000000000  then
  113.             m.write(tostring(math.floor(e/1000000 * mult + 0.5)/mult))
  114.             m.write("mRF/t")
  115.         elseif e >= 1000000000 and e < 1000000000000  then
  116.             m.write(tostring(math.floor(e/1000000000 * mult + 0.5)/mult))
  117.             m.write("gRF/t")
  118.         elseif e == 0 then
  119.             m.setCursorPos(10,21)
  120.             m.write("0RF/t")
  121.         else
  122.             m.write(tostring(curIn))
  123.             m.write("RF/t")
  124.         end
  125.  
  126.  
  127.         --Write Output RF--
  128.  
  129.         m.setCursorPos(center-42, 25)
  130.         e = im.getOutput()
  131.         if e >= 1000 and e < 1000000  then
  132.             m.write(tostring(math.floor(e/1000 * mult + 0.5)/mult))
  133.             m.write("kRF/t")
  134.         elseif e >= 1000000 and e < 1000000000  then
  135.             m.write(tostring(math.floor(e/1000000 * mult + 0.5)/mult))
  136.             m.write("mRF/t")
  137.         elseif e >= 1000000000 and e < 1000000000000  then
  138.             m.write(tostring(math.floor(e/1000000000 * mult + 0.5)/mult))
  139.             m.write("gRF/t")
  140.         elseif e == 0 then
  141.             m.setCursorPos(10,25)
  142.             m.write("0RF/t")
  143.         else
  144.             m.write(tostring(curOut))
  145.             m.write("RF/t")
  146.         end
  147.  
  148.  
  149.         --Write Transfer Cap--
  150.  
  151.         m.setTextColor(colors.white)
  152.         InputOut = 0
  153.         m.setCursorPos(center-42, 29)
  154.         e = im.getTransferCap()
  155.         if e >= 1000 and e < 1000000  then
  156.             m.write(string.format("%.0f", math.floor(e/1000 * mult + 0.5)/mult))
  157.             m.write("kRF")
  158.         elseif e >= 1000000 and e < 1000000000  then
  159.             m.write(string.format("%.0f", math.floor(e/1000000 * mult + 0.5)/mult))
  160.             m.write("mRF")
  161.         elseif e >= 1000000000 and e < 1000000000000  then
  162.             m.write(string.format("%.0f", math.floor(e/1000000000 * mult + 0.5)/mult))
  163.             m.write("gRF")
  164.         else
  165.             m.write(tostring(tfCap))
  166.             m.write("RF")
  167.         end
  168.        
  169.  
  170.  
  171.         --Draw Power Bar--
  172.        
  173.         powBar = math.floor((curPow/maxPow)*(monX/2)+0.5)
  174.         m.setBackgroundColor(colors.orange)
  175.         m.setCursorPos(31,13)
  176.         m.write(string.rep(" ",(monX/2)+2))
  177.         m.setCursorPos(31,14)
  178.         m.write(string.rep(" ",(monX/2)+2))
  179.         m.setCursorPos(31,15)
  180.         m.write(string.rep(" ",(monX/2)+2))
  181.         m.setCursorPos(31,16)
  182.         m.write(string.rep(" ",(monX/2)+2))
  183.         m.setCursorPos(31,17)
  184.         m.write(string.rep(" ",(monX/2)+2))
  185.  
  186.         m.setBackgroundColor(colors.purple)
  187.         m.setCursorPos(32,14)
  188.         m.write(string.rep(" ",(monX/2)))
  189.         m.setCursorPos(32,15)
  190.         m.write(string.rep(" ",(monX/2)))
  191.         m.setCursorPos(32,16)
  192.         m.write(string.rep(" ",(monX/2)))
  193.  
  194.         m.setBackgroundColor(colors.lime)
  195.         m.setCursorPos(32,14)
  196.         m.write(string.rep(" ", powBar))
  197.         m.setCursorPos(32,15)
  198.         m.write(string.rep(" ", powBar))
  199.         m.setCursorPos(32,16)
  200.         m.write(string.rep(" ", powBar))
  201.         m.setBackgroundColor(colors.black)
  202.        
  203.  
  204.         --Write Power Bar Text--
  205.  
  206.         m.setCursorPos(31,11)
  207.         m.write("Charge: "..charge.."%")
  208.  
  209.  
  210.         --Write Transfer Cap Bar--
  211.  
  212.         tBar = math.floor(((curIn+curOut)/tfCap)*(monX/2)+0.5)
  213.         m.setBackgroundColor(colors.orange)
  214.         m.setCursorPos(31,24)
  215.         m.write(string.rep(" ",(monX/2)+2))
  216.         m.setCursorPos(31,25)
  217.         m.write(string.rep(" ",(monX/2)+2))
  218.         m.setCursorPos(31,26)
  219.         m.write(string.rep(" ",(monX/2)+2))
  220.         m.setCursorPos(31,27)
  221.         m.write(string.rep(" ",(monX/2)+2))
  222.         m.setCursorPos(31,28)
  223.         m.write(string.rep(" ",(monX/2)+2))
  224.  
  225.         m.setBackgroundColor(colors.cyan)
  226.         m.setCursorPos(32,25)
  227.         m.write(string.rep(" ",(monX/2)))
  228.         m.setCursorPos(32,26)
  229.         m.write(string.rep(" ",(monX/2)))
  230.         m.setCursorPos(32,27)
  231.         m.write(string.rep(" ",(monX/2)))
  232.  
  233.         m.setBackgroundColor(colors.red)
  234.         m.setCursorPos(32,25)
  235.         m.write(string.rep(" ", tBar))
  236.         m.setCursorPos(32,26)
  237.         m.write(string.rep(" ", tBar))
  238.         m.setCursorPos(32,27)
  239.         m.write(string.rep(" ", tBar))
  240.         m.setBackgroundColor(colors.black)
  241.  
  242.  
  243.         --Write Transfer Bar Text--
  244.  
  245.         m.setCursorPos(31,22)
  246.         m.write("Transfer Usage: "..tUse.."%")
  247.        
  248.    
  249.         sleep(.25)
  250.  
  251.     end
Advertisement
Add Comment
Please, Sign In to add comment