Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. local reactor = peripheral.wrap("BigReactors-Reactor_0")
  2. local mon = peripheral.wrap("monitor_0")
  3. local cap = peripheral.wrap("tile_blockcapacitorbank_name_0")
  4. local active = true
  5.  
  6. function ShowReactorInfo()
  7.    
  8.     mon.setCursorPos(1,1)
  9.     mon.setTextColor(colors,lime)
  10.     mon.write("Reactor Status: ")
  11.     if reactor.getActive() == true then
  12.         mon.setTextColor(colors,green)
  13.         mon.write("ON")
  14.     else
  15.         mon.setTextColor(colors,red)
  16.         mon.write("OFF")
  17.     end
  18.    
  19.     mon.setCursorPos(1,2)
  20.     mon.setTextColor(colors,lime)
  21.     mon.write("RF/t: ")
  22.       mon.setTextColor(colors.lime)
  23.     mon.write(math.floor(reactor.getEnergyProducedLastTick()))
  24.    
  25.     mon.setCursorPos(1,3)
  26.     mon.setTextColor(colors.white)
  27.     mon.write("Energy Buffer: ")
  28.     mon.setTextColor(colors.lime)
  29.     mon.write(math.floor(reactor.getEnergyStored()))
  30.     mon.write(" RF")
  31.    
  32.     mon.setCursorPos(1,4)
  33.     mon.setTextColor(colors.white)
  34.     mon.write("Energy Buffer is ")
  35.     mon.setTextColor(colors.red)
  36.     mon.write(math.floor(reactor.getEnergyStored() * 0.00001))
  37.     mon.write(" % filled")
  38.    
  39.     mon.setCursorPos(1,5)
  40.     mon.setTextColor(colors.white)
  41.     mon.write("Casing Heat: ")
  42.     mon.setTextColor(colors.lime)
  43.     mon.write(math.floor(reactor.getCasingTemperature()))
  44.     mon.write(" °C")
  45.    
  46.     mon.setCursorPos(1,6)
  47.     mon.setTextColor(colors.white)
  48.     mon.write("Fuel/t: ")
  49.     mon.setTextColor(colors.lime)
  50.     mon.write(math.floor(reactor.getFuelConsumedLastTick()))
  51.     mon.write(" mB")
  52.    
  53. end
  54.  
  55. function ShowCapInfo()
  56.     mon.setCursorPos(1,8)
  57.     mon.setTextColor(colors.white)
  58.     mon.write("Capacitor Energy: ")
  59.     mon.setTextColor(colors.lime)
  60.     mon.write(math.floor(cap.getEndergyStored()))
  61.     mon.write(" RF/ ")
  62.     mon.write(math.floor(cap.getMaxEndergyStored()))
  63.    
  64.     mon.setCursorPos(1,9)
  65.     mon.setTextColor(colors.white)
  66.     mon.write("Capacitor is ")
  67.     mon.write(math.floor(cap.getMaxEndergyStored()/cap.getEndergyStored()))
  68.     mon.write(" % filled")
  69. end
  70.  
  71. function CheckStorage()
  72.  
  73.     local perc = math.floor(cap.getMaxEndergyStored()/cap.getEndergyStored())
  74.     local limit = 20
  75.     local energyBuffer = math.floor(reactor.getEnergyStored())
  76.    
  77.     if (perc <= limit and energyBuffer <= 98) then
  78.         reactor.setActive(true)
  79.     elseif (energyBuffer >= 99) then
  80.         reactor.setActive(false)
  81.     end
  82.    
  83.     if (perc < limit-5) then
  84.         print("WARNING! LOW ENERGY LEVEL!")
  85.         active = false
  86.     end
  87. end
  88.  
  89. while active == true do
  90.     ShowReactorInfo()
  91.     ShowCapInfo()
  92.     CheckStorage()
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement