Advertisement
BlazePhoenix

reactorProgram

Nov 19th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. monitor = peripheral.wrap("left")
  2. reactor = peripheral.find("BigReactors-Reactor")
  3. battery = peripheral.find("tile_blockcapacitorbank_name")
  4.  
  5. local steamReactor = reactor.isActivelyCooled()
  6. local numCapacitors = 1
  7. local turnOnPercent = 50
  8. local turnOffPercent = 90
  9.  
  10. local energy = 0
  11. local energyStored = 0
  12. local energyMax = 0
  13. local energyStoredPercent = 0
  14. local timerCode
  15. local RFProduction = 0
  16. local fuelUse = 0
  17.  
  18. local coreTemp = 0
  19. local reactorOnline = false
  20. local rodLevel = 0
  21.  
  22. function writeWithColor(text, color)
  23.     monitor.setTextColor(color)
  24.     monitor.write(text)
  25.     monitor.setTextColor(colors.white)
  26. end
  27.  
  28. function checkStatus()
  29.     local tempEnergy = 0
  30.     energyStored = battery.getEnergyStored()
  31.     energyMax = battery.getMaxEnergyStored()
  32.     energyStoredPercent = math.floor((energyStored/energyMax)*100)
  33.     RFProduction = reactor.getEnergyProducedLastTick()
  34.     fuelUse = reactor.getFuelConsumedLastTick()
  35.     coreTemp = reactor.getFuelTemperature()
  36.     reactorOnline = reactor.getActive()
  37.     tempEnergy = battery.getEnergyStored()
  38.     sleep(0.1)
  39.     energy = (battery.getEnergyStored()-tempEnergy)/2
  40.     energy = energy * numCapacitors
  41. end
  42.  
  43. function displayStatus()
  44.     monitor.clear()
  45.     monitor.setCursorPos(1,1)
  46.     monitor.write("Rector Online: ")
  47.     if reactorOnline then
  48.         writeWithColor("Online", colors.green)
  49.     else
  50.         writeWithColor("Offline", colors.red)
  51.     end
  52.    
  53.     monitor.setCursorPos(1,2)
  54.     monitor.write("Stored Power: ")
  55.     writeWithColor(energy, colors.lightBlue)
  56.    
  57.     monitor.setCursorPos(1,3)
  58.     monitor.write("Stored Percent: ")
  59.     writeWithColor(energyStoredPercent, colors.lime)
  60.     mointor.write("%")
  61.    
  62.     monitor.setCursorPos(1,4)
  63.     monitor.write("RF/t: ")
  64.     if RFProduction > 0 then
  65.         writeWithColor(RFProduction, colors.green)
  66.     else
  67.         writeWithColor(RFProduction, colors.grey)
  68.     end
  69.    
  70. end
  71.  
  72. while true do
  73.     checkStatus()
  74.     displayStatus()
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement