Kohjen

Reactor monitor

Nov 29th, 2020 (edited)
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.12 KB | None | 0 0
  1. -- pastebin get b6DDeput startup
  2.  
  3. reactor = peripheral.wrap("left")
  4. monitor = peripheral.wrap("front")
  5. MAXWIDTH = 29
  6. MAXHIGHT = 26
  7. GRAPHMAX = 20
  8. FUELMAX = reactor.getFuelAmountMax()
  9. ENERGYMAX = reactor.getEnergyCapacity()
  10. HEATMAX = 2000
  11. monitor.setBackgroundColour(32768)
  12. monitor.clear()
  13. monitor.setCursorBlink(false)
  14. while(reactor.getActive)
  15. do
  16.  
  17.    
  18.     fuel = reactor.getFuelAmount()
  19.     reactorEnergy = reactor.getEnergyStored()
  20.     controlRodLevel = reactor.getControlRodLevel(1)
  21.     energy = reactor.getEnergyStored()
  22.     heat = reactor.getFuelTemperature()
  23.  
  24.  
  25.     --Level marker for reactor fuel Level
  26.     monitor.setBackgroundColour(32768)
  27.     monitor.setTextColor(1)
  28.     monitor.setCursorPos(1,1)
  29.     monitor.write("Fuel Level:")
  30.     monitor.setCursorPos(1,2)
  31.     monitor.write("--------------------")
  32.     for i=3,5,1
  33.     do
  34.         for j = 1, GRAPHMAX, 1
  35.         do
  36.             monitor.setCursorPos(j,i)
  37.             if(0<j and j<=5)
  38.  
  39.             then
  40.                 monitor.setBackgroundColour(16384)
  41.                 if( ((fuel/FUELMAX)*20) >= j )
  42.                 then
  43.                     monitor.setTextColor(1)
  44.                 else
  45.                     monitor.setTextColor(16384)
  46.                 end
  47.                 monitor.write("|")
  48.             elseif(5<j and j<=10)
  49.             then
  50.                 monitor.setBackgroundColour(2)
  51.                 if( ((fuel/FUELMAX)*20) >= j )
  52.                 then
  53.                     monitor.setTextColor(1)
  54.                 else
  55.                     monitor.setTextColor(2)
  56.                 end
  57.                 monitor.write("|")
  58.             elseif(10<j)
  59.             then
  60.                 monitor.setBackgroundColour(8192)
  61.                 if( ((fuel/FUELMAX)*20) >= j )
  62.                 then
  63.                     monitor.setTextColor(1)
  64.                 else
  65.                     monitor.setTextColor(8192)
  66.                    
  67.                 end
  68.                 monitor.write("|")
  69.             end
  70.  
  71.         end
  72.     end
  73.    
  74.     --Energy Level marker
  75.     monitor.setBackgroundColour(32768)
  76.     monitor.setTextColor(1)
  77.     monitor.setCursorPos(1,6)
  78.     monitor.write("Energy Level:")
  79.     monitor.setCursorPos(1,7)
  80.     monitor.write("--------------------")
  81.     for i=8,10,1
  82.     do
  83.         for j = 1, GRAPHMAX, 1
  84.         do
  85.  
  86.             monitor.setCursorPos(j,i)
  87.             if(0<j and j<=10)
  88.                 then
  89.                     monitor.setBackgroundColour(8192)
  90.                 if( ((energy/ENERGYMAX)*20) >= j )
  91.                 then
  92.                     monitor.setTextColor(1)
  93.                 else
  94.                     monitor.setTextColor(8192)
  95.             end
  96.             monitor.write("|")
  97.             elseif(10<j and j<=15)
  98.             then
  99.                 monitor.setBackgroundColour(2)
  100.                 if( ((energy/ENERGYMAX)*20) >= j )
  101.                 then
  102.                     monitor.setTextColor(1)
  103.                 else
  104.                     monitor.setTextColor(2)
  105.                 end
  106.                 monitor.write("|")
  107.             elseif(15<j)
  108.             then
  109.                 monitor.setBackgroundColour(16384)
  110.                 if( ((energy/ENERGYMAX)*20) >= j )
  111.                 then
  112.                     monitor.setTextColor(1)
  113.                 else
  114.                     monitor.setTextColor(16384)
  115.                 end
  116.                 monitor.write("|")
  117.             end
  118.            
  119.         end
  120.     end
  121.  
  122.     --Heat Level
  123.     monitor.setBackgroundColour(32768)
  124.     monitor.setTextColor(1)
  125.     monitor.setCursorPos(1,11)
  126.     monitor.write("Heat Level:")
  127.     monitor.setCursorPos(1,12)
  128.     monitor.write("--------------------")
  129.     for i=13,15,1
  130.     do
  131.         for j = 1, GRAPHMAX, 1
  132.         do
  133.             monitor.setCursorPos(j,i)
  134.             if(0<j and j<=10)
  135.             then
  136.                 monitor.setBackgroundColour(8192)
  137.             if( ((heat/HEATMAX)*20) >= j )
  138.                 then
  139.                     monitor.setTextColor(1)
  140.                 else
  141.                     monitor.setTextColor(8192)
  142.                 end
  143.                 monitor.write("|")
  144.             elseif(10<j and j<=15)
  145.             then
  146.                 monitor.setBackgroundColour(2)
  147.                 if( ((heat/HEATMAX)*20) >= j )
  148.                 then
  149.                     monitor.setTextColor(1)
  150.                 else
  151.                     monitor.setTextColor(2)
  152.                 end
  153.                 monitor.write("|")
  154.             elseif(15<j)
  155.             then
  156.                 monitor.setBackgroundColour(16384)
  157.                 if( ((heat/HEATMAX)*20) >= j )
  158.                 then
  159.                     monitor.setTextColor(1)
  160.                 else
  161.                     monitor.setTextColor(16384)
  162.                 end
  163.                 monitor.write("|")
  164.             end
  165.  
  166.         end
  167.     end
  168.     --Control rod Level
  169.     monitor.setBackgroundColour(32768)
  170.     monitor.setTextColor(1)
  171.     monitor.setCursorPos(21,2)
  172.     monitor.write(" Control")
  173.     monitor.setCursorPos(21,3)
  174.     monitor.write("   Rod:")
  175.     monitor.setCursorPos(21,4)
  176.     monitor.write("  ")
  177.     monitor.write(math.floor((controlRodLevel/100) *100))
  178.     monitor.write("%")
  179.     monitor.setCursorPos(21,5)
  180.     monitor.write("---------")
  181.  
  182.  
  183.     for i=21, 29 ,1
  184.     do
  185.         for j = 6, MAXHIGHT, 1
  186.         do
  187.             monitor.setCursorPos(i,j)
  188.  
  189.             if( (((controlRodLevel/100) * 20) + 6) >= j and 22<i and i<28)
  190.             then
  191.                 monitor.setTextColor(32768)
  192.             else
  193.                 monitor.setTextColor(16)
  194.             end
  195.             monitor.setBackgroundColour(16)
  196.  
  197.             monitor.write("|")
  198.            
  199.         end
  200.     end
  201.  
  202.     --Control rod adjustment
  203.     inverseEnergyLvl = math.floor((energy/ENERGYMAX) * 100)
  204.     reactor.setAllControlRodLevels(inverseEnergyLvl)
  205.     --power per tic reader
  206.     monitor.setTextColor(1)
  207.     monitor.setBackgroundColour(32768)
  208.     monitor.setCursorPos(1,16)
  209.     monitor.write("Power Per Tick:")
  210.     monitor.setCursorPos(1,17)
  211.     monitor.write("--------------------")
  212.     monitor.setCursorPos(1,18)
  213.     monitor.write(reactor.getEnergyProducedLastTick())
  214.  
  215.     sleep(.1)
  216.  
  217. --End WhileLoop
  218. end
  219.  
Add Comment
Please, Sign In to add comment