Advertisement
Corbinhol

ReactorController

Jul 14th, 2021 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. component = require("component");
  2. reactor = component.br_reactor;
  3. con = 0;
  4. minCon = 0;
  5. hourCon = 0;
  6. maxPowerMin = 0;
  7.  
  8. secInMin = 0;
  9. minInHour = 0;
  10.  
  11. minConDis = 0;
  12. maxPowerDis = 0;
  13.  
  14. addfuelP = 0;
  15.  
  16. fuelPerRFAvg = 0;
  17.  
  18. reactorStat = "OFFLINE";
  19. computerStatus = "idle";
  20. lastMessage = "System Online";
  21. os.execute("resolution 50 25");
  22. function getPowerConsumed()
  23.         return 10000000 - reactor.getEnergyStored();
  24. end
  25.  
  26. function fuelPerRf()
  27.     return  reactor.getFuelConsumedLastTick() / reactor.getEnergyProducedLastTick();
  28. end
  29.  
  30. while true do
  31.     con = math.floor(getPowerConsumed());
  32.     minCon = minCon + con;
  33.    
  34.     addfuelP = addfuelP + fuelPerRf();
  35.    
  36.     if reactor.getActive() == true then reactorStat = "ONLINE";
  37.     else reactorStat = "OFFLINE";
  38.     end
  39.    
  40.    
  41.     if con > maxPowerMin then
  42.         maxPowerMin = con;
  43.     end
  44.    
  45.     secInMin = secInMin + 1;
  46.     if secInMin == 60 then
  47.         minConDis = math.floor(minCon / 60);
  48.         minCon = 0;
  49.         secInMin = 0;
  50.        
  51.         maxPowerDis = maxPowerMin;
  52.         maxPowerMin = 0;
  53.        
  54.         fuelPerRFAvg = addfuelP / 60;
  55.         addfuelP = 0;
  56.     end
  57.     yelloriumIngot = fuelPerRFAvg / 144;
  58.    
  59.     yelloriumNeeded = (yelloriumIngot * minConDis) * 20;
  60.     os.execute("clear");
  61.     print("Reactor Status: " .. reactorStat);
  62.     print("Reactor Control: " .. computerStatus);
  63.     print("Last Message: " .. lastMessage);
  64.     print("---------------------------------------");
  65.     print("Power Consumed Per Second: " .. tostring(con));
  66.     print("Power Consumed Per Minute: " .. tostring(minConDis));
  67.     print("Maximum Power Consumed Per Minute: " ..tostring(maxPowerDis));
  68.     print("---------------------------------------");
  69.     print("Yellorium MB per Rf: " .. fuelPerRFAvg);
  70.     print("Yellorium Ingots per Rf: " .. yelloriumIngot);
  71.     print("Yellorium needed per second: " .. yelloriumNeeded);
  72.     print("---------------------------------------");
  73.    
  74.     os.sleep(1)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement