Advertisement
Acroneous

Power Monitor

Jul 30th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 KB | None | 0 0
  1. cell = peripheral.wrap("draconic_rf_storage_0")
  2. mon = peripheral.wrap("right")
  3. maxE = "2.14 trillion rf/t"
  4. curE = cell.getEnergyStored()
  5. eStored = ""
  6. eGained = ""
  7. status = ""
  8. ePrintStored = ""
  9.  
  10.  
  11. function main()
  12.     mon.clear()
  13.     staticDisplay()
  14.     eFirstStored = cell.getEnergyStored()
  15.     sleep(1)
  16.     eSecondStored = cell.getEnergyStored()
  17.     -------------------------------------------------------------------------------------------
  18.     -- Shortened length for Energy value
  19.     -------------------------------------------------------------------------------------------
  20.     eStoredToString = tostring(eStored)
  21.     eSub = eStoredToString
  22.     if string.len(eSub) <= 6 then
  23.         ePrintStored = string.sub(eSub, 4).."Thousand rf"
  24.     elseif string.len(eSub) <= 7 and string.len(esub) >= 9 then
  25.         ePrintStored = string.sub(eSub, 7).."Mil rf" 100-
  26.     elseif string.len(esub) <= 9 and string.len(esub) >= 12 then
  27.         ePrintStored = string.sub(eSub, 10).. "Bil rf"
  28.     elseif string.len == 13 then
  29.         ePrintStored = string.sub(13).. "Tril rf"
  30.     end
  31.     -------------------------------------------------------------------------------------------
  32.     -- Get Energy created per second
  33.     -------------------------------------------------------------------------------------------
  34.     if eFirstStored < eSecondStored then
  35.         eGain = eSecondStored - eFirstStored
  36.         eGainToString = tostring(eGain)
  37.  
  38.         if string.len(eGainToString) <= 6 then
  39.         eGainToString = string.sub(eSub, 4).."Thousand rf"
  40.         elseif string.len(eGainToString) <= 7 and string.len(eGainToString) >= 9 then
  41.             ePrintGained = string.sub(eSub, 7).."Mil rf"
  42.         elseif string.len(eGainToString) <= 9 and string.len(eGainToString) >= 12 then
  43.             ePrintGained = string.sub(eSub, 10).. "Bil rf"
  44.         elseif string.len(eGainToString) == 13 then
  45.             ePrintGained = string.sub(eSub, 13).. "Tril rf"
  46.         end
  47.     end
  48.     if curE < 1000000000 then
  49.         redstone.setBundledOutput("bottom", colors.black)
  50.         status = "Active"      
  51.     elseif curE > 1000000000 then
  52.         redstone.setBundledOutput("bottom", colors.0)
  53.         status = "Inactive"
  54.     end
  55. end
  56.  
  57. function staticDisplay()
  58.   mon.clear()
  59.   main()
  60.   mon.setTextColor(colors.white)
  61.   mon.setBackgroundColor(colors.black)
  62.   mon.setTextScale(1)
  63.   mon.setCursorPos(8,1)
  64.   mon.write("Power Storage Monitor")
  65.   mon.setCursorPos(1,4)
  66.   mon.write("Energy Stored: "..ePrintStored)
  67.   mon.setCursorPos(1,6)
  68.   mon.write("Energy Gained: "..ePrintGained)
  69.   mon.setCursorPos(1,10)
  70.   mon.write("Generator Status: "..status)
  71. end
  72.  
  73. while true do
  74.     staticDisplay()
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement