Advertisement
Guest User

powermon

a guest
Oct 10th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.95 KB | None | 0 0
  1. local version = "1.5beta"
  2. r = peripheral.find("BigReactors-Reactor")
  3. mon = peripheral.wrap("monitor_1")
  4. bank = peripheral.find("draconicevolution_tileenergypylon")
  5. timer = 0
  6. time0 = 0
  7. time1 = 0
  8. term.clear()
  9. if r then
  10.  
  11. else
  12. term.setCursorPos(1,1)
  13. error("Reactor not found")
  14. end
  15.  
  16. if mon then
  17.  
  18. else
  19. term.setCursorPos(1,1)
  20. error("Monitor not found")
  21. end
  22. mon.clear()
  23. r.setActive(true)
  24. --Information Loop
  25. while true do
  26.  --Checking if reactor was disconnected while program was running
  27.    mon = peripheral.find("monitor")
  28.    r = peripheral.find("BigReactors-Reactor")
  29.  if r then
  30.  
  31.  else
  32.  term.clear()
  33.  term.setCursorPos(1,1)
  34.  error("Reactor was disconnected")
  35.  end
  36.  
  37.  if mon then
  38.  
  39.  else
  40.  term.clear()
  41.  term.setCursorPos(1,1)
  42.  error("Monitor was disconnected")
  43.  end
  44.  
  45.  if r.getEnergyProducedLastTick() == nil then
  46.  error("There seems to be a chunk boundary between the computer and reactor. This program will not function if this is true")
  47.  end
  48.    term.setTextColor(colors.white)
  49.    mon.setTextColor(colors.white)
  50.    term.setCursorPos(1,1)
  51.    mon.setCursorPos(1,1)
  52.    --SCALE OF THE TEXT ON MONITOR
  53.    mon.setTextScale(1)
  54.    write("Power Status:")
  55.    mon.write("Power Status:")
  56.    term.setCursorPos(1,2)
  57.    mon.setCursorPos(1,2)
  58.    rproduced = r.getEnergyProducedLastTick()
  59.    term.setTextColor(colors.green)
  60.    mon.setTextColor(colors.green)
  61.    write("Generated: "..(math.floor(rproduced+0,5).." RF/t              "))
  62.    mon.write("Generated: "..(math.floor(rproduced+0,5).." RF/t              "))
  63.    mon.setTextColor(colors.white)
  64.    term.setCursorPos(1,3)
  65.    mon.setCursorPos(1,3)
  66.    bankstored = bank.getEnergyStored()
  67.    bankmax = bank.getMaxEnergyStored()
  68.    storedenergy = r.getEnergyStored()
  69.     if storedenergy < 500000 then
  70.      term.setTextColor(colors.red)
  71.      mon.setTextColor(colors.red)
  72.      write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  73.      mon.write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  74.      
  75.     elseif storedenergy > 7000000 then
  76.      term.setTextColor(colors.green)
  77.      mon.setTextColor(colors.green)
  78.      write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  79.      mon.write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  80.     elseif storedenergy > 500000 then
  81.      term.setTextColor(colors.orange)
  82.      mon.setTextColor(colors.orange)
  83.      write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  84.      mon.write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  85.     else
  86.      term.setTextColor(colors.green)
  87.      mon.setTextColor(colors.green)
  88.      write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  89.      mon.write("Stored (Reactor): "..math.floor(r.getEnergyStored()+0,5).." RF           ")
  90.     end
  91.    
  92.    term.setCursorPos(1,4)
  93.    mon.setCursorPos(1,4)
  94.    write("Stored (Bank): "..bankstored.." / "..bankmax.." RF           ")
  95.    mon.write("Stored (Bank): "..bankstored.." / "..bankmax.." RF           ")
  96.    term.setCursorPos(1,7)
  97.    mon.setCursorPos(1,7)
  98.    term.setTextColor(colors.white)
  99.    mon.setTextColor(colors.white)
  100.    write("Reactor Status:")
  101.    mon.write("Reactor Status:")
  102.    term.setCursorPos(1,8)
  103.    mon.setCursorPos(1,8)
  104.    term.setTextColor(colors.white)
  105.    mon.setTextColor(colors.white)
  106.    term.setCursorPos(1,10)
  107.    mon.setCursorPos(1,10)
  108.    write("Fuel Status:")
  109.    mon.write("Fuel Status:")
  110.    if r.getActive() == true then
  111.     term.setTextColor(colors.green)
  112.     mon.setTextColor(colors.green)
  113.     term.setCursorPos(1,8)
  114.     mon.setCursorPos(1,8)
  115.     write("Online ")
  116.     mon.write("Online ")
  117.     mon.setTextColor(colors.white)
  118.     else
  119.      term.setTextColor(colors.red)
  120.      mon.setTextColor(colors.red)
  121.      term.setCursorPos(1,8)
  122.      mon.setCursorPos(1,8)
  123.      write("Offline")
  124.      mon.write("Offline")
  125.      term.setTextColor(colors.white)
  126.      mon.setTextColor(colors.white)
  127.      end
  128.    
  129.    term.setCursorPos(1,11)
  130.    mon.setCursorPos(1,11)
  131.    coretemp = r.getFuelTemperature()
  132.    if coretemp < 1000 then
  133.    term.setTextColor(colors.green)
  134.    write("Core Temp: "..math.floor(coretemp+0,5).." C (Low)                    ")
  135.    mon.setTextColor(colors.green)
  136.    mon.write("Core Temp: "..math.floor(coretemp+0,5).." C (Low)              ")
  137.    elseif coretemp > 2000 then
  138.    term.setTextColor(colors.red)
  139.    write("Core Temp: "..math.floor(coretemp+0,5).." C (High!)                    ")
  140.    mon.setTextColor(colors.red)
  141.    mon.write("Core Temp: "..math.floor(coretemp+0,5).." C (High!)              ")
  142.    elseif coretemp > 1000 then
  143.    term.setTextColor(colors.orange)
  144.    write("Core Temp: "..math.floor(coretemp+0,5).." C (Medium)                   ")
  145.    mon.setTextColor(colors.orange)
  146.    mon.write("Core Temp: "..math.floor(coretemp+0,5).." C (Medium)              ")
  147.    end
  148.    term.setTextColor(colors.orange)
  149.    term.setCursorPos(1,12)
  150.    mon.setTextColor(colors.orange)
  151.    mon.setCursorPos(1,12)
  152.    fuelreactivity = r.getFuelReactivity()
  153.    write("Fuel Reactivity: "..math.floor(fuelreactivity+5).."%          ")
  154.    mon.write("Fuel Reactivity: "..math.floor(fuelreactivity+5).."%          ")
  155.    term.setCursorPos(1,13)
  156.    mon.setCursorPos(1,13)
  157.    fuelburn = r.getFuelConsumedLastTick()/1000
  158.    write("Fuel Burnup: "..fuelburn.." ingots/t          ")
  159.    mon.write("Fuel Burnup: "..fuelburn.." ingots/t          ")
  160.    fuelamount = r.getFuelAmount()/1000
  161.    wasteamount = r.getWasteAmount()/1000
  162.    maxfuel = r.getFuelAmountMax()/1000
  163.    term.setCursorPos(1,14)
  164.    mon.setCursorPos(1,14)
  165.    write("Fuel Amount: "..fuelamount.." ingots          ")
  166.    mon.write("Fuel Amount: "..fuelamount.." ingots          ")
  167.    term.setCursorPos(1,15)
  168.    mon.setCursorPos(1,15)
  169.    write("Waste Amount: "..wasteamount.." ingots          ")
  170.    mon.write("Waste Amount: "..wasteamount.." ingots          ")
  171.    term.setCursorPos(1,16)
  172.    mon.setCursorPos(1,16)
  173.    write("Maximal Fuel: "..maxfuel.." ingots")
  174.    mon.write("Maximal Fuel: "..maxfuel.." ingots")
  175.    w,h = mon.getSize()
  176.    term.setCursorPos(1,20)
  177.    mon.setCursorPos(1,h)
  178.    time0 = time0+1
  179.    if time0 == 600 then
  180.    time1 = time1+1
  181.    time0 = 0
  182.    end
  183.    if time1 == 1 then
  184.    write("Running: "..time1.." minute    ")
  185.    mon.write("Running: "..time1.." minute    ")
  186.    else
  187.    write("Running for "..time1.." minutes ")
  188.    mon.write("Running: "..time1.." minutes ")
  189.    end
  190.    mon.setCursorPos(12,19)
  191.    --mon.write("  ")
  192.    mon.setTextColor(colors.white)
  193.     timer = timer+1
  194.     if timer == 2 then
  195.     gen2 = (r.getEnergyProducedLastTick())
  196.     in2 = (r.getEnergyStored())
  197.     used = (in1+gen2-in2)
  198.     term.setCursorPos(1,5)
  199.     mon.setCursorPos(1,5)
  200.       if used > rproduced then
  201.      term.setTextColor(colors.red)
  202.      mon.setTextColor(colors.red)
  203.      write("Usage (Reactor): "..math.floor(used+0,5).." RF/t                           ")
  204.      mon.write("Usage (Reactor): "..math.floor(used+0,5).." RF/t                            ")
  205.       elseif used < rproduced then
  206.      mon.setTextColor(colors.green)
  207.      term.setTextColor(colors.green)
  208.      write("Usage (Reactor): "..math.floor(used+0,5).." RF/t                           ")
  209.      mon.write("Usage (Reactor): "..math.floor(used+0,5).." RF/t                            ")
  210.       else
  211.      term.setTextColor(colors.white)
  212.      mon.setTextColor(colors.white)
  213.      write("Usage (Reactor): "..math.floor(used+0,5).." RF/t (Calculation Error)                                  ")
  214.      mon.write("Usage (Reactor): "..math.floor(used+0,5).." RF/t (Calculation Error)                                  ")
  215.    end
  216.     timer = (timer-2)
  217.     else
  218.     gen1 = (r.getEnergyProducedLastTick())
  219.     in1 = (r.getEnergyStored())
  220.    end
  221.    if storedenergy > 9900000 and r.getActive() == true then
  222.     r.setActive(false)
  223.     errorfix = true
  224.    elseif storedenergy < 9900000 and errorfix == true then
  225.     r.setActive(true)
  226.     errorfix = false
  227.    end
  228.    sleep(0,1)
  229. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement