Suppenbiatch

Reactor New

Jun 22nd, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.52 KB | None | 0 0
  1. function round(num, idp)
  2.   local mult = 10^(idp or 0);
  3.   return math.floor(num * mult + 0.5) / mult;
  4. end
  5.  
  6. function formateNumber(n) --http://richard.warburton.it
  7.     if type(n) == "number" then
  8.         n = string.format("%.f", tostring(n))
  9.     else
  10.         n = string.format("%.f", n)
  11.     end
  12.     local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$');
  13.     return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right;
  14. end
  15.  
  16. local monitor = peripheral.wrap("monitor_1")
  17. local reactor = {}
  18. local i = 0
  19.  
  20. monitor.clear()
  21. monitor.setTextColor(colors.combine(colors.orange, colors.yellow))
  22. monitor.setTextScale(.75)
  23.  
  24. for i = 0, 5, 1 do
  25.     reactor[i] = peripheral.wrap("Reactor Logic Adapter_" .. i)
  26. end
  27.  
  28. while true do
  29.  
  30.     i = 0
  31.     local totalEnergy = 0
  32.    
  33.     for _ in pairs(reactor) do
  34.    
  35.         local Energy = reactor[i].getEnergy()
  36.         local MaxEnergy = reactor[i].getMaxEnergy()
  37.         local EnergyOut = reactor[i].getProducing()
  38.         local PlasmaHeat = reactor[i].getPlasmaHeat()
  39.         local CaseHeat = reactor[i].getCaseHeat()
  40.         local MaxCaseHeat = reactor[i].getMaxCaseHeat()
  41.         local MaxPlasmaHeat = reactor[i].getMaxPlasmaHeat()
  42.         local IgnitionTemp = reactor[i].getIgnitionTemp()
  43.         local Tritium = reactor[i].getTritium()
  44.         local Deuterium = reactor[i].getDeuterium()
  45.         local FuelInjectionRate = reactor[i].getInjectionRate()
  46.         local Water = reactor[i].getWater()
  47.         local Steam = reactor[i].getSteam()
  48.         local isOn = reactor[i].isIgnited()
  49.         local canStart = reactor[i].canIgnite()
  50.        
  51.        
  52.         monitor.setCursorPos(1,1)
  53.         monitor.clearLine()
  54.         if isOn then
  55.             monitor.setTextColor(colors.lime)
  56.             monitor.write("Reactor " .. i+1 .. " is ON")
  57.         else
  58.             monitor.setTextColor(colors.red)
  59.             monitor.write("Reactor " .. i+1 .. " is OFF")
  60.         end
  61.        
  62.        
  63.         monitor.setTextColor(colors.combine(colors.orange, colors.yellow))
  64.         monitor.setCursorPos(1,3)
  65.         monitor.clearLine()
  66.         monitor.write("Case Temperature:   " .. formateNumber(CaseHeat) .. " K this corresponds to " .. round((CaseHeat/MaxCaseHeat)*100,2) .. " % of the max Case Temperature.")
  67.         monitor.setCursorPos(1,5)
  68.         monitor.clearLine()
  69.         monitor.write("Plasma Temperature: " .. formateNumber(PlasmaHeat) .. " K this corresponds to " .. round((PlasmaHeat/MaxPlasmaHeat)*100,2) .. " % of the max Plasma Temperature.")
  70.         monitor.setCursorPos(1,7)
  71.         monitor.clearLine()
  72.         monitor.write("Need Temperature for Ignition: " .. formateNumber(IgnitionTemp) .. " K this corresponds to " .. round((PlasmaHeat/IgnitionTemp)*100,5) .. " % of the current Plasma Temperature.")
  73.        
  74.         monitor.setCursorPos(1,10)
  75.         monitor.clearLine()
  76.         monitor.write("Currently Producing:      " .. formateNumber(EnergyOut/2.5) .. " RF/t at an Fuel Injection Rate of " .. FuelInjectionRate .. " mB/t.")
  77.         monitor.setCursorPos(1,12)
  78.         monitor.clearLine()
  79.         monitor.write("Current stored Energy:    " .. formateNumber(Energy/2.5) .. " RF this corresponds to " .. round((Energy/MaxEnergy)*100,4) .. " % of the max storable Energy.")
  80.         monitor.setCursorPos(1,14)
  81.         monitor.clearLine()
  82.         monitor.write("Current stored Tritium:   " .. formateNumber(Tritium) .. " mB.")
  83.         monitor.setCursorPos(1,16)
  84.         monitor.clearLine()
  85.         monitor.write("Current stored Deuterium: " .. formateNumber(Deuterium) .. " mB.")
  86.        
  87.         monitor.setCursorPos(1,18)
  88.         monitor.clearLine()
  89.         monitor.write("Current stored Water: " .. formateNumber(Water) .. " mB.")
  90.        
  91.         monitor.setCursorPos(1,20)
  92.         monitor.clearLine()
  93.         monitor.write("Current stored Steam: " .. formateNumber(Steam) .. " mB.")
  94.        
  95.         monitor.setCursorPos(1,23)
  96.         monitor.clearLine()
  97.        
  98.         if canStart then
  99.             monitor.setTextColor(colors.lime)
  100.             monitor.write("Reactor could be re- started.")
  101.         else
  102.             monitor.setTextColor(colors.red)
  103.             monitor.write("Reactor could NOT be re- started without a Laser Impuls.")
  104.         end
  105.                
  106.         monitor.setTextColor(colors.combine(colors.orange, colors.yellow))
  107.        
  108.         i = i + 1
  109.         totalEnergy = totalEnergy + EnergyOut
  110.         os.sleep(3.5)
  111.     end
  112.    
  113.     monitor.setCursorPos(1,25)
  114.     monitor.clearLine()
  115.     monitor.write("Total Energy Production: " .. formateNumber(totalEnergy/2.5) .. " RF/t")
  116.    
  117. end
Add Comment
Please, Sign In to add comment