Advertisement
Guest User

Basic Induction Matrix Monitor

a guest
Jun 3rd, 2025
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function Check()
  3.   if peripheral.find("Induction Matrix") == nil then
  4.     else cube = peripheral.find("Induction Matrix")
  5.       name = "Induction Matrix"
  6.   end
  7.   return name
  8. end
  9.  
  10. function progress_bar(percentage)
  11.   count = 0
  12.   total = 50
  13.   start = '['
  14.   last = ']'
  15.   used = ''
  16.   empty = ''
  17.   for i=0, math.floor(percentage / 2) do
  18.       used = used .. "|"
  19.       count = count + 1
  20.   end
  21.   for i=0, total - math.floor(percentage / 2) do
  22.       empty = empty .. "-"
  23.       count = count + 1
  24.   end
  25.  
  26.   t_monitor.setTextColor(colors.white)
  27.   t_monitor.write(start)
  28.  
  29.   t_monitor.setTextColor(colors.white)
  30.   t_monitor.write(used)
  31.  
  32.   t_monitor.setTextColor(colors.gray)
  33.   t_monitor.write(empty)
  34.  
  35.   t_monitor.setTextColor(colors.white)
  36.   t_monitor.write(last)
  37.   return raw
  38. end
  39.  
  40.  
  41.  
  42. monitor = peripheral.wrap("right")
  43. t_monitor = peripheral.wrap("top")
  44.  
  45. previous = 0
  46.  
  47. function eng_cube()
  48.   monitor.clear()
  49.   monitor.setCursorPos(1,1)
  50.   monitor.setTextScale(0.8)
  51.   monitor.write(string.format("Showing Data For [%s]", name))
  52.  
  53.   max = cube.getMaxEnergy()
  54.   monitor.setCursorPos(1,2)
  55.   monitor.write(string.format("Capacity: %s J", max))
  56.  
  57.   current = cube.getEnergy()
  58.   e_in = current - previous
  59.   previous = current
  60.   monitor.setCursorPos(1,3)
  61.   monitor.write(string.format("I/O(+/-): %s J/T", e_in))
  62.  
  63.   monitor.setCursorPos(1,4)
  64.   monitor.write(string.format("Stored  : %s J", current))
  65. end
  66.  
  67.  
  68. function matrix()
  69.  
  70.   monitor.clear()
  71.   monitor.setCursorPos(1,1)
  72.   monitor.setTextScale(0.9)
  73.   monitor.write("Power Managment")
  74.   monitor.setCursorPos(1,2)
  75.   monitor.write(string.format("[%s]", name))
  76.  
  77.   max = cube.getMaxEnergy()
  78.   monitor.setCursorPos(1,3)
  79.   monitor.write(string.format("Capacity   : %s J", max))
  80.  
  81.   e_in = cube.getInput()
  82.   monitor.setCursorPos(1,4)
  83.   monitor.write(string.format("Receiving  : %s J/T", e_in))
  84.  
  85.   e_out = cube.getOutput()
  86.   monitor.setCursorPos(1,5)
  87.   monitor.write(string.format("Outputting : %s J/T", e_out))
  88.  
  89.   current = cube.getEnergy()
  90.   monitor.setCursorPos(1,6)
  91.   monitor.write(string.format("Stored     : %s J", current))
  92.  
  93.   cur_perc = (current / max) * 100
  94.   cur_perc = math.floor(cur_perc+0.5)
  95.  
  96.   t_monitor.clear()
  97.   t_monitor.setCursorPos(1,1)
  98.   t_monitor.setTextScale(0.9)
  99.   t_monitor.write(string.format("Stored     : %s Percent", cur_perc))
  100.  
  101.   t_monitor.setCursorPos(1,3)
  102.   val_max = progress_bar(cur_perc)
  103.  
  104.   cap = cube.getTransferCap()
  105.   out_perc = (e_out / cap) * 100
  106.   out_perc = math.floor(out_perc+0.5)
  107.   t_monitor.setCursorPos(1,5)
  108.   t_monitor.write(string.format("Outputting : %s Percent", out_perc))
  109.  
  110.  
  111.   t_monitor.setCursorPos(1,6)
  112.   val_out = progress_bar(out_perc)
  113.  
  114.  
  115.   in_perc = (e_in / cap) * 100
  116.   in_perc = math.floor(in_perc+0.5)
  117.   t_monitor.setCursorPos(1,8)
  118.   t_monitor.write(string.format("Receiving  : %s Percent", in_perc))
  119.  
  120.  
  121.   t_monitor.setCursorPos(1,9)
  122.   val_in = progress_bar(in_perc)
  123.  
  124. end
  125.  
  126. while true do
  127.   Check()
  128.   if name == "Induction Matrix"
  129.   then
  130.     matrix()
  131.     sleep(0.1)
  132.   else
  133.     eng_cube()
  134.     sleep(0.05)
  135.   end
  136. end
  137.  
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement