StreamerYT

(More energy mods) + OC : ENERGY

Aug 2nd, 2018 (edited)
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --===== screen resolution =====
  2. local width = 50
  3. local height = 25
  4.  
  5. --===== background ============
  6. local bg = 0x000000
  7. --===== border color ==========
  8. local brbg = 0x000000
  9. local brfg = 0xFFFFFF
  10. --===== text color =============
  11. local Tfg = 0xffffff
  12. --===== bar color ==============
  13. local Bbg = 0xff00f0
  14. local Bfg = 0x00ffff
  15. --========================================
  16.  
  17. local eformat = {
  18. "Thousand",
  19. "Million",
  20. "Billions",
  21. "Trillion",
  22. "Quadrillion",
  23. "Quintillion",
  24. }
  25.  
  26. local blocks = {
  27. ---------- ---------- ----------
  28. ------------- IC2 --------------
  29.     {"mfsu","EU"},
  30.     {"mfe","EU"},
  31. ----------- AFSU MOD -----------
  32.     {"afsu","EU"},
  33. ----------- Mekanism -----------
  34.     {"___________________________","RF"},
  35.     {"____________________","RF"},
  36. ------- Matter Overdrive -------
  37.     {"_________________________________","RF"},
  38. ------- Thermal Expansion ------
  39.     {"tile_thermalexpansion_cell_resonant_name","RF"}
  40. ---------- ---------- ----------
  41. }
  42.  
  43. local c = require "component"
  44. local g = c.gpu
  45.  
  46. function bgreset()
  47.     g.setBackground(bg)
  48.     g.setForeground(Tfg)
  49. end
  50.  
  51. function text(x,y,t)
  52.     bgreset()
  53.     g.set(x,y,t)
  54. end
  55.  
  56. function energyFormat(i)
  57.     i = tostring(i)
  58.     local wordid = math.ceil(i:len() / 3)-1
  59.     local word = ""
  60.     if wordid>0 then
  61.         word = eformat[wordid]
  62.     end
  63.     local t = string.sub(i,0,i:len()-(wordid*3))
  64.     return t .. " " .. word
  65. end
  66.  
  67. function bar(x,y,i,t)
  68.     g.setBackground(Bbg)
  69.     g.fill(x+8,y,width-11-x+2,1," ");
  70.     g.setBackground(Bfg)
  71.     g.fill(x+8,y,(((width-11-x+2)/100)*i),1," ");
  72.    
  73.     local c=0x000000
  74.     if i<=25 then
  75.         c=0xff0000
  76.     elseif i<=50 then
  77.         c=0xf05000
  78.     elseif i<=75 then
  79.         c=0xfff000
  80.     elseif i<=100 then
  81.         c=0x00ff00
  82.     end
  83.    
  84.     text(x,y,t)
  85.    
  86.     g.setBackground(bg)
  87.     g.setForeground(c)
  88.     g.set(x+3,y,i.."  ")
  89.     g.set(x+6,y,"%")
  90. end
  91.  
  92. function gui()
  93.     bgreset()
  94.     g.setResolution(width,height)
  95.    
  96.     g.setBackground(brbg)
  97.     g.setForeground(brfg)
  98.    
  99.     c.gpu.fill(2,1,width-2,1,"═");
  100.     c.gpu.fill(width,1,1,1,"╗");
  101.     c.gpu.fill(width,2,1,height-2,"║");
  102.     c.gpu.fill(width,height,1,1,"╝");
  103.     c.gpu.fill(2,height,width-2,1,"═");
  104.     c.gpu.fill(1,height,1,1,"╚");
  105.     c.gpu.fill(1,2,1,height-2,"║");
  106.     c.gpu.fill(1,1,1,1,"╔");
  107.     c.gpu.fill(12,2,1,9,"║");
  108.     c.gpu.fill(29,2,1,9,"║");
  109.     c.gpu.fill(2,3,44,1,"═");
  110.     c.gpu.fill(2,5,44,1,"═");
  111.     c.gpu.fill(2,7,44,1,"═");
  112.     c.gpu.fill(2,9,44,1,"═");
  113.     c.gpu.fill(2,11,44,1,"═");
  114.     c.gpu.fill(46,2,1,9,"║");
  115.     text(46,11,"╝");
  116.     text(29,7,"╬")
  117.     text(29,5,"╬")
  118.     text(29,3,"╬")
  119.     text(29,9,"╬")
  120.     text(12,7,"╬")
  121.     text(12,5,"╬")
  122.     text(12,9,"╬")
  123.     text(12,3,"╬")
  124.     text(12,1,"╦")
  125.     text(46,1,"╦")
  126.     text(29,1,"╦")
  127.     text(12,11,"╩")
  128.     text(29,11,"╩")
  129.     text(46,9,"╣")
  130.     text(46,7,"╣")
  131.     text(46,5,"╣")
  132.     text(46,3,"╣")
  133.    
  134.     text(14,2,"EU")
  135.     text(31,2,"RF")
  136.     text(3,2,"Type")
  137.     text(3,4,"Blocks")
  138.     text(3,6,"Energy")
  139.     text(3,8,"Maximum")
  140.     text(3,10,"Energy/s")
  141.    
  142.     text(width-30,height-1,"Created: StreamerYT (FYfSDrAD)")
  143. end
  144. for screen,n in c.list("screen") do
  145.         screen = c.proxy(screen)
  146.         g.bind(screen.address)
  147.        
  148.         g.fill(1,1,width,height," ");
  149. end
  150.  
  151. local EU1 = 0
  152. local RF1 = 0
  153.  
  154. function run()
  155.    
  156.     local EU = 0.0001
  157.     local EUmax = 0.0001
  158.     local EUs = 0
  159.    
  160.     local RF = 0.0001
  161.     local RFmax = 0.0001
  162.     local RFs = 0
  163.  
  164.     for i in pairs(blocks) do
  165.         local block = blocks[i]
  166.         for a, n in c.list(block[1]) do
  167.             cmp = c.proxy(a)
  168.             if block[2] == "RF" then
  169.                 RFs = RFs + 1
  170.                 RFmax = RFmax + cmp.getMaxEnergyStored()
  171.                 RF = RF + cmp.getEnergyStored()
  172.             else
  173.                 EUs = EUs + 1
  174.                 EUmax = EUmax + cmp.getEUCapacity()
  175.                 EU = EU + cmp.getEUStored()
  176.             end
  177.         end
  178.     end
  179.    
  180.    
  181.    
  182.    
  183.     local EUp = math.floor((100 / EUmax) * EU)
  184.     local EUsec = math.floor(EU - EU1)
  185.     EU1 = EU
  186.     for screen,n in c.list("screen") do
  187.         screen = c.proxy(screen)
  188.         g.bind(screen.address)
  189.        
  190.         text(14,4,EUs.."          ")
  191.         text(14,10,EUsec.."          ")
  192.         text(14,6,math.floor(EU).."          ")
  193.         text(14,8,math.floor(EUmax).."          ")
  194.         if EUs==0 then
  195.             bar(3,height-5,0,"EU");
  196.         else
  197.             bar(3,height-5,EUp,"EU");
  198.         end
  199.        
  200.        
  201.        
  202.         local RFp = math.floor((100 / RFmax) * RF)
  203.         local RFsec = math.floor(RF - RF1)
  204.         RF1 = RF
  205.        
  206.         text(31,4,RFs.."          ")
  207.         text(31,10,RFsec.."          ")
  208.         text(31,6,math.floor(RF).."          ")
  209.         text(31,8,math.floor(RFmax).."          ")
  210.         if RFs==0 then
  211.             bar(3,height-3,0,"RF")
  212.         else
  213.             bar(3,height-3,RFp,"RF")
  214.         end
  215.         gui()
  216.     end
  217. end
  218.  
  219. function test()
  220.     run()
  221.     os.sleep(0.1)
  222. end
  223.  
  224. function start()
  225.     while true do
  226.         run()
  227.         os.sleep(1)
  228.     end
  229. end
  230. start()
Add Comment
Please, Sign In to add comment