Advertisement
Guest User

Basic Induction Matrix Monitor

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