Guest User

graphProd

a guest
Nov 16th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. function Clear()
  2.     term.clear()
  3.     term.setCursorPos(1,1)
  4. end
  5.  
  6. function Abreger(nb, idp)
  7.     if nb >= 1000000000000000000000000 then
  8.         nb = nb / 1000000000000000000000000
  9.         mult = 10^ (idp or 0)
  10.         nb = math.floor(nb * mult + 0.5) / mult
  11.         return (nb.."Y")
  12.     elseif nb >= 1000000000000000000000 then
  13.         nb = nb / 1000000000000000000000
  14.         mult = 10^ (idp or 0)
  15.         nb = math.floor(nb * mult + 0.5) / mult
  16.         return (nb.."Z")
  17.     elseif nb >= 1000000000000000000 then
  18.         nb = nb / 1000000000000000000
  19.         mult = 10^ (idp or 0)
  20.         nb = math.floor(nb * mult + 0.5) / mult
  21.         return (nb.."E")
  22.     elseif nb >= 1000000000000000 then
  23.         nb = nb / 1000000000000000
  24.         mult = 10^ (idp or 0)
  25.         nb = math.floor(nb * mult + 0.5) / mult
  26.         return (nb.."P")
  27.     elseif nb >= 1000000000000 then
  28.         nb = nb / 1000000000000
  29.         mult = 10^ (idp or 0)
  30.         nb = math.floor(nb * mult + 0.5) / mult
  31.         return (nb.."T")
  32.     elseif nb >= 1000000000 then
  33.         nb = nb / 1000000000
  34.         mult = 10^ (idp or 0)
  35.         nb = math.floor(nb * mult + 0.5) / mult
  36.         return (nb.."G")
  37.     elseif nb >= 1000000 then
  38.         nb = nb / 1000000
  39.         mult = 10^ (idp or 0)
  40.         nb = math.floor(nb * mult + 0.5) / mult
  41.         return (nb.."M")
  42.     elseif nb >= 1000 then
  43.         nb = nb / 1000
  44.         mult = 10^ (idp or 0)
  45.         nb = math.floor(nb * mult + 0.5) / mult
  46.         return (nb.."K")
  47.  else
  48.   return nb
  49.  end
  50. end
  51.  
  52. function entier(nb)
  53.     nb1 = math.floor(nb)
  54.     nb2 = nb - nb1
  55.     if nb2 >= 0.5 then
  56.         return math.ceil(nb)
  57.     else
  58.         return nb1
  59.     end
  60. end
  61.  
  62. side = "top", "bottom", "back", "front", "right", "left"
  63. mon = peripheral.wrap(side)
  64. term.redirect(mon)
  65.  
  66. typePeripheralReacteur = "BigReactors-Reactor_"
  67. nbTypePeripheralReacteur = 0
  68. echelle = 0
  69.  
  70. xx, y = term.getSize()
  71. paintutils.drawFilledBox(1, 1, xx, y, colors.black)
  72. Clear()
  73. xGraph = 6
  74. yGraph = 0
  75.  
  76. term.setTextColor(colors.white)
  77.  
  78. paintutils.drawFilledBox(1, 1, xx, y, colors.black)
  79. Clear()
  80.  
  81. tour = 0
  82.  
  83. for tour=1,30 do
  84.    
  85.     reac = peripheral.wrap(typePeripheralReacteur..nbTypePeripheralReacteur)
  86.    
  87.     if reac ~= nil then
  88.         energyProd = entier(reac.getEnergyProducedLastTick())
  89.         nbTypePeripheralReacteur = 0
  90.     else
  91.         nbTypePeripheralReacteur = nbTypePeripheralReacteur + 1
  92.     end
  93.  
  94.     sleep(0.5)
  95.  
  96. end
  97.  
  98. echelle = tonumber(energyProd + 200)
  99.  
  100. while true do
  101.  
  102.     xx, y = term.getSize()
  103.  
  104.     paintutils.drawFilledBox(1, 1, 6, y, colors.black)
  105.     term.setCursorPos(1,3)
  106.     print(Abreger(echelle, 1))
  107.     term.setCursorPos(3,y)
  108.     print("0")
  109.     paintutils.drawLine(6, y, 6, 1, colors.gray)
  110.  
  111.     while true do
  112.  
  113.         reac = peripheral.wrap(typePeripheralReacteur..nbTypePeripheralReacteur)
  114.  
  115.         if reac ~= nil then
  116.             energyProd = entier(reac.getEnergyProducedLastTick())
  117.             nbTypePeripheralReacteur = 0
  118.             break
  119.         else
  120.             nbTypePeripheralReacteur = nbTypePeripheralReacteur + 1
  121.         end
  122.  
  123.     end
  124.    
  125.     pourcent = entier(energyProd / echelle * y)
  126.     xGraph = xGraph + 1
  127.     yGraph = y - pourcent
  128.  
  129.     if yGraph < 1 then
  130.         yGraph = 1
  131.     end
  132.    
  133.     if yGraph < y / 4 then
  134.         color = colors.green
  135.     elseif yGraph < y / 2 then
  136.         color = colors.yellow
  137.     elseif yGraph < y / 4 * 3 then
  138.         color = colors.orange
  139.     else
  140.         color = colors.red
  141.     end
  142.  
  143.     if xGraph > xx then
  144.         paintutils.drawFilledBox(7, 1, xx, y, colors.black)
  145.         xGraph = 7
  146.     end
  147.  
  148.         paintutils.drawLine(xGraph, yGraph, xGraph, y, color)
  149.    
  150.     sleep(0.1)
  151.  
  152. end
Advertisement
Add Comment
Please, Sign In to add comment