Advertisement
Guest User

a

a guest
Aug 28th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. reactor1 = peripheral.wrap("BigReactors-Reactor_0")
  2. mon = peripheral.wrap("monitor_2")
  3. x, y = 1, 1
  4. maxX, maxY = mon.getSize()
  5. lastRFStored = reactor1.getEnergyStored()
  6.  
  7. function showHeading(title)
  8.  mon.setTextColor(colors.lightBlue)
  9.     mon.setCursorPos((maxX - #title) / 2, y)
  10.     mon.write(title)
  11.     y = y + 1
  12. end
  13.  
  14. function showInfo(desc, val, coloring, maxVal)
  15.     mon.setCursorPos((maxX / 2) - #desc, y)
  16.     mon.setTextColor(colors.black)
  17.     mon.write(desc)
  18.     mon.setTextColor(colors.lime)
  19.     if(type(val) == "number") then
  20.         val = math.floor(val)    
  21.     end
  22.     if(coloring == 1) then
  23.         setTextColorLowBad(val, maxVal)
  24.     elseif(coloring == 2) then
  25.         setTextColorHighBad(val, maxVal)
  26.     end
  27.     mon.write(val)
  28.     y = y + 1
  29. end
  30.  
  31. function setTextColorLowBad(val, maxVal)
  32.     if(type(val) == "boolean") then
  33.         if(val == true) then
  34.             mon.setTextColor(colors.lime)
  35.         else
  36.             mon.setTextColor(colors.red)
  37.         end
  38.     elseif(type(val) == "number") then
  39.         local pct = val / maxVal
  40.         if(pct <= 0.33) then
  41.             mon.setTextColor(colors.red)
  42.         elseif(pct <= 0.66) then
  43.             mon.setTextColor(colors.orange)
  44.         else
  45.             mon.setTextColor(colors.lime)
  46.         end
  47.     end
  48. end
  49.  
  50. function setTextColorHighBad(val, maxVal)
  51.     if(type(val) == "boolean") then
  52.         if(val == true) then
  53.             mon.setTextColor(colors.red)
  54.         else
  55.             mon.setTextColor(colors.lime)
  56.         end
  57.     elseif(type(val) == "number") then
  58.         local pct = val / maxVal
  59.         if(pct <= 0.33) then
  60.             mon.setTextColor(colors.lime)
  61.         elseif(pct <= 0.66) then
  62.             mon.setTextColor(colors.orange)
  63.         else
  64.             mon.setTextColor(colors.red)
  65.         end
  66.     end
  67. end
  68.  
  69. while true do
  70.     x, y = 1, 1
  71.     mon.clear()
  72.     mon.setBackgroundColor(colors.white)
  73.    
  74.    
  75.     showHeading("GENERAL INFO")
  76.     showInfo("Active", reactor1.getActive(), 1, 0)
  77.     local energyInc = false
  78.     if(reactor1.getEnergyStored() > lastRFStored) then
  79.         energyInc = true
  80.     end
  81.     showInfo("Sustainable", energyInc, 1, 0)
  82.     showHeading("ENERGY INFO")
  83.     showInfo("RF/T", reactor1.getEnergyProducedLastTick(),1, 260)
  84.     showInfo("RF Stored", reactor1.getEnergyStored(), 1, 1000000)
  85.     showHeading("TEMPERATURE INFO")
  86.     showInfo("Casing Heat", reactor1.getCasingTemperature(), 2, 1000)
  87.     showInfo("Fuel Heat", reactor1.getFuelTemperature(), 2, 1000)
  88.     lastRFStored = reactor1.getEnergyStored()
  89.     sleep(2.5)
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement